Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nginx container to run site instead of apache #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .docker/nginx/site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80 default_server;
listen [::]:80 default_server;

index index.php index.html;
server_name _;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

root /var/www/html/;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
7 changes: 1 addition & 6 deletions Dockerfile → Dockerfile-php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-apache
FROM php:7.2-fpm

ARG build_env=production

Expand All @@ -14,12 +14,8 @@ RUN apt-get update \
sudo \
unzip \
zip \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g bower \
&& docker-php-ext-install pdo pdo_mysql \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& mv "${PHP_INI_DIR}/php.ini-${build_env}" "${PHP_INI_DIR}/php.ini" \
Expand All @@ -29,5 +25,4 @@ RUN apt-get update \
&& mkdir -p /var/www/.config \
&& chown www-data:www-data /var/www/ \
&& chown www-data:www-data /var/www/.config \
&& sudo -u www-data /bin/bash -c "bower install --production" \
&& sudo -u www-data /bin/bash -c "composer install --no-dev --optimize-autoloader"
19 changes: 19 additions & 0 deletions Dockerfile-web
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM nginx:latest

COPY . /var/www/html

WORKDIR /var/www/html

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
sudo \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g bower \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/www/.config \
&& chown -R www-data:www-data /var/www/ \
&& sudo -u www-data /bin/bash -c "bower install --production"
14 changes: 12 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ services:
web:
build:
context: .
args:
build_env: production
dockerfile: Dockerfile-web
volumes:
- .docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
depends_on:
- php

php:
build:
context: .
dockerfile: Dockerfile-php
args:
build_env: production
volumes:
- .admin_config.php:/var/www/html/.admin_config.php
- .db_config.php:/var/www/html/.db_config.php
Expand Down