From d8a161648195a3e15b3ce336c0dc5e4c651bf67d Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 9 Feb 2021 14:37:50 +0000 Subject: [PATCH] Add local environment with Docker Compose --- .dockerignore | 7 +++ docker-compose.yaml | 52 ++++++++++++++++++++ tools/docker/Dockerfile | 35 +++++++++++++ tools/docker/images/nginx/configs/vhost.conf | 19 +++++++ tools/docker/images/php/configs/php.ini | 2 + 5 files changed, 115 insertions(+) create mode 100644 .dockerignore create mode 100644 docker-compose.yaml create mode 100644 tools/docker/Dockerfile create mode 100644 tools/docker/images/nginx/configs/vhost.conf create mode 100644 tools/docker/images/php/configs/php.ini diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ea3f4b4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/**/*.{md,txt} +/.git-blame-ignore-revs +/.git/ +/.github/ +/.gitignore +/.idea/ +/.notes/ diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6665356 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,52 @@ +version: '2.4' + +networks: + public: + external: + name: traefik_proxy + +volumes: + node_modules: ~ + +services: + nginx: + image: nginx:1 + working_dir: /app + volumes: + - ./:/app + - ./tools/docker/images/nginx/configs/vhost.conf:/etc/nginx/conf.d/default.conf + # ports: + # - 9000:80 + depends_on: + node: + condition: service_started + php: + condition: service_started + networks: + default: {} + public: {} + labels: + - traefik.docker.network=traefik_proxy + - traefik.enable=true + - traefik.http.routers.workshop-tailwind.rule=Host(`workshop-tailwind.docker.localhost`) + + php: + build: + context: . + dockerfile: tools/docker/Dockerfile + target: dev + volumes: + - ./:/app + networks: + default: {} + labels: + - "traefik.enable=false" + + node: + image: node:12 + working_dir: /node/app + volumes: + - .:/node/app + - node_modules:/node/app/node_modules + labels: + - "traefik.enabled=false" diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile new file mode 100644 index 0000000..1ceec73 --- /dev/null +++ b/tools/docker/Dockerfile @@ -0,0 +1,35 @@ +fROM php:7.3-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 diff --git a/tools/docker/images/nginx/configs/vhost.conf b/tools/docker/images/nginx/configs/vhost.conf new file mode 100644 index 0000000..2e6954c --- /dev/null +++ b/tools/docker/images/nginx/configs/vhost.conf @@ -0,0 +1,19 @@ +server { + server_name _; + root /app/public; + + 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; + } +} diff --git a/tools/docker/images/php/configs/php.ini b/tools/docker/images/php/configs/php.ini new file mode 100644 index 0000000..b59ac11 --- /dev/null +++ b/tools/docker/images/php/configs/php.ini @@ -0,0 +1,2 @@ +date.timezone=UTC +expose_php=Off