From 663750953be8a9fba6608953c85a4f4187d3e546 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 13 Sep 2021 20:26:16 +0100 Subject: [PATCH] Add Docker Compose files --- Dockerfile | 12 ++++++++---- Makefile | 12 ++++++++++++ docker-compose-prod.yaml | 35 +++++++++++++++++++++++++++++++++++ docker-compose.yaml | 30 ++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 docker-compose-prod.yaml create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index 47a2b4c..e37e4e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,20 +2,24 @@ ARG NODE_VERSION=14 # A node container for generating the CSS and JS assets for the site, copying # in only the minimal files that are needed to do this. Once this is done, the -# node dependencies can be installed using yarn, and Encore can be run to -# generate the assets. +# node dependencies can be installed using yarn, and Encore can be run via the +# Makefile to generate the assets. FROM node:${NODE_VERSION} AS assets WORKDIR /app +COPY Makefile . COPY package.json . COPY yarn.lock . COPY webpack.config.js . COPY source source -RUN yarn install --frozen-lockfile FROM assets AS assets-build -RUN yarn encore dev +RUN make build-assets + +FROM assets AS assets-watch +RUN make watch-assets FROM opdavies/sculpin AS sculpin +WORKDIR /app COPY composer.* ./ WORKDIR /app/source COPY --from=assets-build /app/source/build build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a48fb3 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +node_modules: + yarn install --frozen-lockfile + +build-assets: node_modules + yarn encore production + +watch-assets: node_modules + yarn encore dev --watch + +.PHONY: watch-assets + +# vim: noexpandtab diff --git a/docker-compose-prod.yaml b/docker-compose-prod.yaml new file mode 100644 index 0000000..c499f8c --- /dev/null +++ b/docker-compose-prod.yaml @@ -0,0 +1,35 @@ +version: '2.4' + +services: + app: + build: + context: . + target: sculpin + volumes: + - assets:/app/source/build + - ./:/app + working_dir: /app + entrypoint: sculpin + command: + - generate + - --env + - prod + + assets: + build: + context: . + target: assets-build + environment: + - NODE_ENV=production + volumes: + - assets:/app/source/build + - ./Makefile:/app/Makefile + - ./package.json:/app/package.json + - ./tailwind.config.js:/app/tailwind.config.js + - ./webpack.config.js:/app/webpack.config.js + - ./yarn.lock:/app/yarn.lock + +volumes: + assets: + +# vim: tabstop=2 shiftwidth=2 softtabstop=2 shiftround diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..2175177 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,30 @@ +version: '2.4' + +services: + app: + build: + context: . + target: sculpin-watch + volumes: + - /app/output_dev + - assets:/app/source/build + - ./:/app + ports: + - 8000:8000 + + assets: + build: + context: . + target: assets-watch + volumes: + - assets:/app/source/build + - ./Makefile:/app/Makefile + - ./package.json:/app/package.json + - ./tailwind.config.js:/app/tailwind.config.js + - ./webpack.config.js:/app/webpack.config.js + - ./yarn.lock:/app/yarn.lock + +volumes: + assets: + +# vim: tabstop=2 shiftwidth=2 softtabstop=2 shiftround