Skip to content

Commit

Permalink
Add Docker Compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
opdavies committed Sep 13, 2021
1 parent d60bf53 commit 6637509
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions docker-compose-prod.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6637509

Please sign in to comment.