mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Initial Docker support
This commit adds: 1. A Dockerfile that runs PHP 7.2 FPM on Alpine Linux 2. A example docker-compose file that simplifies deployment
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ Homestead.yaml
|
||||
.rnd
|
||||
/.expo
|
||||
/.vscode
|
||||
docker-compose.yml
|
||||
|
||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
FROM php:7.2-fpm-alpine
|
||||
|
||||
# Use the default production configuration
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
RUN apk add --no-cache curl git tar unzip libpng-dev libxml2-dev
|
||||
|
||||
RUN docker-php-ext-install bcmath && \
|
||||
docker-php-ext-install ctype && \
|
||||
docker-php-ext-install json && \
|
||||
docker-php-ext-install gd && \
|
||||
docker-php-ext-install mbstring && \
|
||||
docker-php-ext-install pdo && \
|
||||
docker-php-ext-install pdo_mysql && \
|
||||
docker-php-ext-install tokenizer && \
|
||||
docker-php-ext-install xml && \
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
|
||||
composer --version
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
COPY . /var/www
|
||||
|
||||
RUN composer install --optimize-autoloader && \
|
||||
php artisan config:cache && \
|
||||
chmod -R 755 storage bootstrap/cache && \
|
||||
chown -R www-data:www-data storage
|
||||
|
||||
EXPOSE 9000
|
||||
CMD ["php-fpm"]
|
||||
|
||||
18
docker-compose.yml.example
Normal file
18
docker-compose.yml.example
Normal file
@ -0,0 +1,18 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
|
||||
nginx:
|
||||
image: nginx
|
||||
expose:
|
||||
- 80
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
restart: always
|
||||
|
||||
php:
|
||||
build: .
|
||||
expose:
|
||||
- 9000
|
||||
restart: always
|
||||
|
||||
74
nginx.conf
Normal file
74
nginx.conf
Normal file
@ -0,0 +1,74 @@
|
||||
worker_processes 8;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 4096;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
root /var/www/public;
|
||||
index index.php;
|
||||
charset utf-8;
|
||||
|
||||
access_log off;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
client_max_body_size 100m;
|
||||
client_body_timeout 120s;
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
sendfile off;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Robots-Tag none;
|
||||
add_header Content-Security-Policy "frame-ancestors 'self'";
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_intercept_errors off;
|
||||
fastcgi_buffer_size 16k;
|
||||
fastcgi_buffers 4 16k;
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
fastcgi_read_timeout 300;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user