mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-29 16:50:12 +02:00
Refactored Docker configuration to allow running both apache and nginx containers for testing
This commit is contained in:
9
.docker/Dockerfile.apache
Normal file
9
.docker/Dockerfile.apache
Normal file
@@ -0,0 +1,9 @@
|
||||
# Build apache image
|
||||
FROM php:7.4-apache
|
||||
LABEL maintainer="Chris Kankiewicz <Chris@ChrisKankiewicz.com>"
|
||||
|
||||
COPY ./php/config/php.ini /usr/local/etc/php/php.ini
|
||||
COPY ./apache/config/000-default.conf /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
RUN a2enmod rewrite
|
||||
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
7
.docker/Dockerfile.nginx
Normal file
7
.docker/Dockerfile.nginx
Normal file
@@ -0,0 +1,7 @@
|
||||
# Build php-fpm image
|
||||
FROM php:7.4-fpm
|
||||
LABEL maintainer="Chris Kankiewicz <Chris@ChrisKankiewicz.com>"
|
||||
|
||||
COPY ./php/config/php.ini /usr/local/etc/php/php.ini
|
||||
|
||||
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
@@ -1,9 +0,0 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/html
|
||||
ServerAdmin Chris@ChrisKankiewicz.com
|
||||
|
||||
LogLevel warn
|
||||
|
||||
ErrorLog /dev/stderr
|
||||
CustomLog /dev/stderr combined
|
||||
</VirtualHost>
|
33
.docker/nginx/config/default.conf
Normal file
33
.docker/nginx/config/default.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
root /var/www/html;
|
||||
index index.php;
|
||||
|
||||
access_log /dev/stderr;
|
||||
error_log /dev/stderr;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ \.php {
|
||||
try_files $uri =404;
|
||||
|
||||
fastcgi_split_path_info ^(.+\.php)(.*)$;
|
||||
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
|
||||
fastcgi_pass php-fpm:9000;
|
||||
fastcgi_index index.php;
|
||||
|
||||
include fastcgi_params;
|
||||
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
[PHP]
|
||||
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
|
||||
log_errors = On
|
||||
memory_limit = -1
|
||||
|
||||
[opcache]
|
||||
opcache.enable = 1
|
||||
opcache.fast_shutdown = 1
|
||||
opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 10000
|
||||
opcache.memory_consumption = 128
|
||||
opcache.optimization_level = 0xffffffff
|
||||
opcache.validate_timestamps = 0
|
||||
|
||||
[xdebug]
|
||||
xdebug.profiler_enable = 0
|
||||
xdebug.remote_autostart = 0
|
||||
xdebug.remote_enable = 0
|
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.git
|
||||
node_modules
|
||||
vendor
|
30
Dockerfile
30
Dockerfile
@@ -1,30 +0,0 @@
|
||||
# Install PHP dependencies
|
||||
FROM composer:1.9 AS php-dependencies
|
||||
COPY . /application
|
||||
RUN composer install --working-dir /application --ignore-platform-reqs \
|
||||
--no-cache --no-dev --no-interaction
|
||||
|
||||
# Install and compile JavaScript assets
|
||||
FROM node:13.6 AS js-dependencies
|
||||
COPY --from=php-dependencies /application /application
|
||||
RUN cd /application && npm install && npm run production
|
||||
|
||||
# Build application image
|
||||
FROM php:7.4-apache as application
|
||||
LABEL maintainer="Chris Kankiewicz <Chris@ChrisKankiewicz.com>"
|
||||
|
||||
COPY --from=js-dependencies /application /var/www/html
|
||||
|
||||
RUN a2enmod rewrite
|
||||
|
||||
# Build development image
|
||||
FROM application as development
|
||||
COPY ./.docker/php/config/php.dev.ini /usr/local/etc/php/php.ini
|
||||
COPY ./.docker/apache2/config/000-default.dev.conf /etc/apache2/sites-available/000-default.conf
|
||||
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
||||
|
||||
# Build production image
|
||||
FROM application as production
|
||||
COPY ./.docker/php/config/php.prd.ini /usr/local/etc/php/php.ini
|
||||
COPY ./.docker/apache2/config/000-default.prd.conf /etc/apache2/sites-available/000-default.conf
|
||||
RUN docker-php-ext-install opcache
|
@@ -1,13 +1,32 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
app:
|
||||
container_name: directory-lister-app
|
||||
apache:
|
||||
container_name: directory-lister-apache
|
||||
build:
|
||||
context: .
|
||||
target: development
|
||||
context: .docker
|
||||
dockerfile: Dockerfile.apache
|
||||
environment:
|
||||
VIRTUAL_HOST: directory-lister.local
|
||||
VIRTUAL_HOST: directory-lister.local,directory-lister.apache.local
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
||||
nginx:
|
||||
container_name: directory-lister-nginx
|
||||
image: nginx:1.17
|
||||
environment:
|
||||
VIRTUAL_HOST: directory-lister.nginx.local
|
||||
volumes:
|
||||
- ./.docker/nginx/config/default.conf:/etc/nginx/conf.d/default.conf
|
||||
- ./:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
||||
php-fpm:
|
||||
container_name: directory-lister-php-fpm
|
||||
build:
|
||||
context: .docker
|
||||
dockerfile: Dockerfile.nginx
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
Reference in New Issue
Block a user