Add Docker and Docker Compose
This commit is contained in:
parent
ebd57a2e69
commit
29d88893fa
4
.docker.env.example
Normal file
4
.docker.env.example
Normal file
|
@ -0,0 +1,4 @@
|
|||
MYSQL_DATABASE=drupal
|
||||
MYSQL_PASSWORD=drupal
|
||||
MYSQL_ROOT_PASSWORD=root
|
||||
MYSQL_USER=drupal
|
7
.dockerignore
Normal file
7
.dockerignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**/*.{md,txt}
|
||||
/.git-blame-ignore-revs
|
||||
/.git/
|
||||
/.github/
|
||||
/.gitignore
|
||||
/.idea/
|
||||
/.notes/
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -2,12 +2,15 @@
|
|||
!*/
|
||||
!/.gitignore
|
||||
!/**/.gitkeep
|
||||
!/.docker.env.example
|
||||
!/.dockerignore
|
||||
!/.github/**
|
||||
!/.idea/
|
||||
!/assets/**
|
||||
!/bin/
|
||||
!/config/**
|
||||
!/Makefile
|
||||
!/Dockerfile
|
||||
!/docker-compose.yaml
|
||||
!/phpcs.xml.dist
|
||||
!/phpstan.neon
|
||||
!/phpunit.xml.dist
|
||||
|
@ -17,6 +20,7 @@
|
|||
!/web/modules/custom/**
|
||||
!/web/sites/default/environments/settings.*.php
|
||||
!/web/sites/default/settings.php
|
||||
!/web/sites/default/settings.docker.php
|
||||
!/web/themes/custom/**
|
||||
/.idea/workspace.xml
|
||||
/node_modules/
|
||||
|
|
69
docker-compose.yaml
Normal file
69
docker-compose.yaml
Normal file
|
@ -0,0 +1,69 @@
|
|||
version: '2.4'
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
|
||||
networks:
|
||||
web:
|
||||
external:
|
||||
name: traefik_proxy
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:1-alpine
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ./:/app
|
||||
- ./tools/docker/images/nginx/configs/vhost.conf:/etc/nginx/conf.d/default.conf
|
||||
depends_on:
|
||||
node:
|
||||
condition: service_started
|
||||
php:
|
||||
condition: service_started
|
||||
networks:
|
||||
default: {}
|
||||
web: {}
|
||||
labels:
|
||||
- traefik.docker.network=traefik_proxy
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.oliverdavies.rule=Host(`oliverdavies.docker.localhost`)
|
||||
|
||||
php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: tools/docker/Dockerfile
|
||||
target: dev
|
||||
volumes:
|
||||
- ./:/app
|
||||
env_file:
|
||||
- .docker.env
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
default: {}
|
||||
labels:
|
||||
- "traefik.enable=false"
|
||||
|
||||
mysql:
|
||||
image: mariadb:10
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
- ./tools/docker/images/mysql/databases.sql:/docker-entrypoint-initdb.d/databases.sql
|
||||
env_file:
|
||||
- .docker.env
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "bash", "-c", "echo > /dev/tcp/localhost/3306"]
|
||||
interval: 1s
|
||||
networks:
|
||||
default: {}
|
||||
labels:
|
||||
- "traefik.enable=false"
|
||||
|
||||
node:
|
||||
image: node:12
|
||||
working_dir: /node
|
||||
volumes:
|
||||
- ./web:/node
|
||||
labels:
|
||||
- "traefik.enabled=false"
|
1
tools/assets/development/.gitignore
vendored
Normal file
1
tools/assets/development/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/*.sql*
|
35
tools/docker/Dockerfile
Normal file
35
tools/docker/Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
|||
FROM php:7.4-fpm-buster AS base
|
||||
|
||||
RUN apt update -yqq && apt install -yqq \
|
||||
git \
|
||||
libpng-dev \
|
||||
mariadb-client \
|
||||
zip \
|
||||
zlib1g-dev \
|
||||
&& docker-php-ext-install \
|
||||
exif \
|
||||
gd \
|
||||
pdo_mysql
|
||||
|
||||
###
|
||||
|
||||
FROM base AS dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PATH="./bin:./vendor/bin:$PATH"
|
||||
|
||||
RUN apt update -yqq \
|
||||
&& apt install -yqq \
|
||||
pv \
|
||||
vim \
|
||||
&& pecl install xdebug-2.9.0 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
COPY --from=composer:1 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
COPY composer.json composer.lock /app/
|
||||
COPY assets /app/assets
|
||||
RUN composer install
|
||||
|
||||
COPY tools/docker/images/php/configs/php.ini /usr/local/etc/php/conf.d/php.ini
|
19
tools/docker/images/nginx/configs/vhost.conf
Normal file
19
tools/docker/images/nginx/configs/vhost.conf
Normal file
|
@ -0,0 +1,19 @@
|
|||
server {
|
||||
server_name _;
|
||||
root /app/web;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
|
||||
try_files $fastcgi_script_name =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_pass php:9000;
|
||||
}
|
||||
}
|
2
tools/docker/images/php/configs/php.ini
Normal file
2
tools/docker/images/php/configs/php.ini
Normal file
|
@ -0,0 +1,2 @@
|
|||
date.timezone=UTC
|
||||
expose_php=Off
|
16
web/sites/default/settings.docker.php
Normal file
16
web/sites/default/settings.docker.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
$databases['default']['default'] = [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'mysql',
|
||||
'database' => getenv('MYSQL_DATABASE'),
|
||||
'username' => getenv('MYSQL_USER'),
|
||||
'password' => getenv('MYSQL_PASSWORD'),
|
||||
'port' => '3306',
|
||||
'prefix' => '',
|
||||
'collation' => 'utf8mb4_general_ci',
|
||||
];
|
||||
|
||||
$settings['trusted_host_patterns'] = [
|
||||
'^oliverdavies.docker.localhost$',
|
||||
];
|
|
@ -764,3 +764,6 @@ if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
|
|||
include $app_root . '/' . $site_path . '/settings.local.php';
|
||||
}
|
||||
|
||||
if (file_exists('/.dockerenv') && file_exists($app_root . '/' . $site_path . '/settings.docker.php')) {
|
||||
include $app_root . '/' . $site_path . '/settings.docker.php';
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ Encore
|
|||
.cleanupOutputBeforeBuild()
|
||||
.setOutputPath('build/')
|
||||
.setPublicPath('/themes/custom/opdavies/build')
|
||||
.setManifestKeyPrefix('build/')
|
||||
|
||||
.addEntry('app', '@/app.js')
|
||||
|
||||
|
|
Loading…
Reference in a new issue