From 13f81622db3b66c9cc3ac9fdbc33642ad078694e Mon Sep 17 00:00:00 2001 From: stuzer05 Date: Mon, 4 Nov 2024 18:07:51 +0200 Subject: [PATCH] Add docker deployment --- Dockerfile | 16 ++++++++++++---- docker/conf/etc/nginx/sites-enabled/default.conf | 12 ++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8bae0f..3fd39a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,14 +68,20 @@ RUN docker-php-ext-install \ pdo_sqlite \ bcmath -# Configure PHP -RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini +# Configure php-fpm +RUN sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php\/php-fpm.sock/' /usr/local/etc/php-fpm.d/www.conf \ + && sed -i 's/;listen.owner = www-data/listen.owner = www-data/' /usr/local/etc/php-fpm.d/www.conf \ + && sed -i 's/;listen.group = www-data/listen.group = www-data/' /usr/local/etc/php-fpm.d/www.conf \ + && sed -i 's/;listen.mode = 0660/listen.mode = 0660/' /usr/local/etc/php-fpm.d/www.conf \ + && cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \ + && sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/' /usr/local/etc/php/php.ini \ + && sed -i 's/post_max_size = 8M/post_max_size = 200M/' /usr/local/etc/php/php.ini # Install Node.js RUN npm install -g n && n 18 # Apply configs -COPY ./docker/conf/* / +COPY ./docker/conf/etc /etc # Configure project WORKDIR /tmp @@ -86,7 +92,9 @@ COPY . . RUN npm install \ && npm run build \ && chown www-data:www-data . -R \ - && mv /tmp/dist/* /tmp/api /var/www/html + && rm -r /var/www/html/* \ + && mv /tmp/dist/* /tmp/api /var/www/html \ + && rm -r /tmp/* WORKDIR /var/www/html diff --git a/docker/conf/etc/nginx/sites-enabled/default.conf b/docker/conf/etc/nginx/sites-enabled/default.conf index 77b9997..a99de0d 100644 --- a/docker/conf/etc/nginx/sites-enabled/default.conf +++ b/docker/conf/etc/nginx/sites-enabled/default.conf @@ -3,17 +3,17 @@ server { server_name default; root /var/www/html; - index index.php; + index index.html; client_max_body_size 5m; client_body_timeout 60; location / { - try_files $uri $uri/ @rewrite; - } + try_files $uri $uri/ /index.html; - location @rewrite { - rewrite ^/(.*)$ /index.php; + if (!-e $request_filename) { + rewrite ^/(.*)$ /index.html last; + } } location ~ \.php$ { @@ -23,7 +23,7 @@ server { } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { - try_files $uri /index.php; + try_files $uri /index.html; expires max; log_not_found off; }