From 6115dc7bc64c8b7b50cba11b4b45d92982defd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 31 May 2020 14:41:53 +0200 Subject: [PATCH] MAPG-92 use Nginx instead of Apache in Docker environment --- docker/Dockerfile | 14 ++++++-------- docker/configs/apache.conf | 15 --------------- docker/configs/nginx.conf | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 docker/configs/apache.conf create mode 100644 docker/configs/nginx.conf diff --git a/docker/Dockerfile b/docker/Dockerfile index 2e68c87..0b3e3d4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,16 +2,14 @@ FROM ubuntu:focal ENV DEBIAN_FRONTEND noninteractive -# Install Apache, PHP and further necessary packages -RUN apt update -RUN apt install -y curl git mariadb-client apache2 \ +# Install Nginx, PHP and further necessary packages +RUN apt update --fix-missing +RUN apt install -y curl git mariadb-client nginx \ php-apcu php-xdebug php7.4-cli php7.4-curl php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-zip -# Configure Apache with PHP +# Configure Nginx with PHP RUN mkdir -p /run/php -RUN a2enmod proxy_fcgi rewrite -RUN a2enconf php7.4-fpm -COPY configs/apache.conf /etc/apache2/sites-available/000-default.conf +COPY configs/nginx.conf /etc/nginx/sites-available/default RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/mods-available/xdebug.ini RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/mods-available/xdebug.ini RUN echo "xdebug.remote_connect_back = 1" >> /etc/php/7.4/mods-available/xdebug.ini @@ -29,4 +27,4 @@ EXPOSE 80 VOLUME /var/www/mapguesser WORKDIR /var/www/mapguesser -ENTRYPOINT /usr/sbin/php-fpm7.4 -F & /usr/sbin/apache2ctl -DFOREGROUND +ENTRYPOINT /usr/sbin/php-fpm7.4 -F & /usr/sbin/nginx -g 'daemon off;' diff --git a/docker/configs/apache.conf b/docker/configs/apache.conf deleted file mode 100644 index 36c8063..0000000 --- a/docker/configs/apache.conf +++ /dev/null @@ -1,15 +0,0 @@ - - ServerName mapguesser-dev.ch - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/mapguesser/public - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - - - Options FollowSymLinks - AllowOverride All - Require all granted - diff --git a/docker/configs/nginx.conf b/docker/configs/nginx.conf new file mode 100644 index 0000000..e566a0c --- /dev/null +++ b/docker/configs/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /var/www/mapguesser/public; + + index index.php index.html index.htm index.nginx-debian.html; + + server_name mapguesser-dev.ch; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; + } + + location ~ /\.ht { + deny all; + } +}