build(docker): make Compose file more configurable
Allow for configuring volume mounts, ports, the site URL, and volume mounts within the Docker Compose file using environment variables from within and .env file. This means that the same Docker Compose file could be used to generate and serve the site locally using an anonymous volume, as well as generate a one-time build into a local directory to be served by Apache or Nginx on production.
This commit is contained in:
parent
e736230805
commit
7fbecb1728
29
.env.example
Normal file
29
.env.example
Normal file
|
@ -0,0 +1,29 @@
|
|||
COMPOSE_PROJECT_NAME=oliverdavies-uk
|
||||
|
||||
# The volume to store the generated output files.
|
||||
#
|
||||
# For development, an anonymous volume should be sufficient as the generated
|
||||
# files don't need to be accessible locally.
|
||||
#
|
||||
# For production, you may want to output the files into a directory so that
|
||||
# they can be served by a web server like Apache or Nginx.
|
||||
#DOCKER_OUTPUT_VOLUME=./output_dev:/app/output_dev
|
||||
#DOCKER_OUTPUT_VOLUME=./output_prod:/app/output_prod
|
||||
DOCKER_OUTPUT_VOLUME=/app/output_dev
|
||||
|
||||
# The environment to generate the site for (e.g. dev or prod).
|
||||
#SCULPIN_ENV=prod
|
||||
SCULPIN_ENV=dev
|
||||
|
||||
# The port on which to serve the site if the --server option is specified.
|
||||
#SCULPIN_PORT=80
|
||||
SCULPIN_PORT=8000
|
||||
|
||||
# The default URL to use if one hasn't been specified in the environment's
|
||||
# configuration file.
|
||||
#SCULPIN_URL=https://example.com
|
||||
SCULPIN_URL=http://localhost
|
||||
|
||||
# Any additional arguments to pass to the "sculpin generate" command.
|
||||
#SCULPIN_GENERATE_ARGS=
|
||||
SCULPIN_GENERATE_ARGS="--server --watch"
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,5 @@
|
|||
/output_*/
|
||||
/source/build/
|
||||
/vendor/
|
||||
/.env
|
||||
/.phpunit.cache
|
||||
|
|
|
@ -1,34 +1,20 @@
|
|||
version: '2.4'
|
||||
|
||||
services:
|
||||
proxy:
|
||||
image: nginxproxy/nginx-proxy:alpine
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
ports:
|
||||
- "${DOCKER_WEB_PORT_FORWARD:-80}:80"
|
||||
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: tools/docker/images/Dockerfile
|
||||
target: app
|
||||
expose:
|
||||
- 80
|
||||
command:
|
||||
- generate
|
||||
- --server
|
||||
- --watch
|
||||
- --port
|
||||
- '80'
|
||||
- --url
|
||||
- http://oliverdavies.localhost
|
||||
command: generate --port "${SCULPIN_PORT:-80}" --url "${SCULPIN_URL:-http://localhost}" --env "${SCULPIN_ENV:-dev}" "${SCULPIN_GENERATE_ARGS}"
|
||||
volumes:
|
||||
- assets:/app/source/build
|
||||
- /app/output_dev
|
||||
- .:/app
|
||||
environment:
|
||||
VIRTUAL_HOST: oliverdavies.localhost
|
||||
- "${DOCKER_OUTPUT_VOLUME:-./output_prod:/app/output_prod}"
|
||||
ports:
|
||||
- "${SCULPIN_PORT:-80}:${SCULPIN_PORT:-80}"
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
- assets
|
||||
|
||||
assets:
|
||||
image: node:14
|
||||
|
@ -50,4 +36,4 @@ services:
|
|||
- assets-watch
|
||||
|
||||
volumes:
|
||||
assets:
|
||||
assets: {}
|
||||
|
|
Loading…
Reference in a new issue