From 65c100a81237274254de3288965429e3d5a99dfb Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 9 May 2021 21:01:32 +0100 Subject: [PATCH] Tidy up Docker environment [ci skip] --- docker-compose.yaml | 39 +++++++++++++++++++++++++++------------ tools/docker/Dockerfile | 21 +++++++++++++++++++-- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 0644ef3..083e726 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,9 @@ version: '2.4' volumes: + assets: mysql_data: + node_modules: services: proxy: @@ -11,15 +13,34 @@ services: volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - nginx: - image: nginx:1-alpine - working_dir: /app + node: + image: node:14-alpine + working_dir: /node + entrypoint: sh volumes: + - assets:/node/build + - node_modules:/node/node_modules + - ./web/themes/custom/opdavies/assets:/node/assets + - ./web/themes/custom/opdavies/package-lock.json:/node/package-lock.json + - ./web/themes/custom/opdavies/package.json:/node/package.json + - ./web/themes/custom/opdavies/postcss.config.js:/node/postcss.config.js + - ./web/themes/custom/opdavies/tailwind-colours.js:/node/tailwind-colours.js + - ./web/themes/custom/opdavies/tailwind-plugin-focus-visible.js:/node/tailwind-plugin-focus-visible.js + - ./web/themes/custom/opdavies/tailwind-safelist-classes.txt:/node/tailwind-safelist-classes.txt + - ./web/themes/custom/opdavies/tailwind.config.js:/node/tailwind.config.js + - ./web/themes/custom/opdavies/templates:/node/templates + - ./web/themes/custom/opdavies/webpack.config.js:/node/webpack.config.js + + nginx: + build: + dockerfile: tools/docker/Dockerfile + context: . + target: nginx + volumes: + - assets:/app/web/themes/custom/opdavies/build + - node_modules:/app/web/themes/custom/opdavies/node_modules - ./:/app - - ./tools/docker/images/nginx/configs/vhost.conf:/etc/nginx/conf.d/default.conf depends_on: - node: - condition: service_started php: condition: service_started environment: @@ -48,9 +69,3 @@ services: healthcheck: test: ["CMD-SHELL", "bash", "-c", "echo > /dev/tcp/localhost/3306"] interval: 1s - - node: - image: node:12 - working_dir: /node - volumes: - - ./web:/node diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 41e9151..f96d250 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -1,3 +1,21 @@ +FROM node:14-alpine AS assets-build +WORKDIR /app/web/themes/custom/opdavies +COPY web/themes/custom/opdavies/package*.json ./ +RUN npm ci +COPY web/themes/custom/opdavies ./ +RUN npm run production + +### + +FROM nginx:1-alpine AS nginx +COPY tools/docker/images/nginx/configs/vhost.conf /etc/nginx/conf.d/default.conf +WORKDIR /app +COPY web web/ +WORKDIR /app/web/themes/custom/opdavies +COPY --from=assets-build /app/web/themes/custom/opdavies/build build + +### + FROM php:7.4-fpm-buster AS base RUN apt update -yqq && apt install -yqq \ @@ -25,6 +43,7 @@ RUN apt update -yqq \ && docker-php-ext-enable xdebug COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +COPY tools/docker/images/php/configs/php.ini /usr/local/etc/php/conf.d/php.ini WORKDIR /app ENV PATH="$PATH:/app/bin" @@ -33,5 +52,3 @@ COPY composer.json composer.lock /app/ COPY assets /app/assets COPY tools/patches /app/tools/patches RUN composer install - -COPY tools/docker/images/php/configs/php.ini /usr/local/etc/php/conf.d/php.ini