From 34ffb96025a756ac2943b3077af7afea61580ed8 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 23 Jul 2021 19:23:13 -0600 Subject: [PATCH] refactor(dockerfile): switch to env file - replace livereload.params with .env - allows subst in compose file itself - activate defaults by default --- livereload.params => .env | 35 +++++++++++++++++++++++++---------- docker-compose.yml | 21 ++++++++++++++++----- 2 files changed, 41 insertions(+), 15 deletions(-) rename livereload.params => .env (82%) diff --git a/livereload.params b/.env similarity index 82% rename from livereload.params rename to .env index f3c66f2..9528424 100644 --- a/livereload.params +++ b/.env @@ -13,7 +13,7 @@ # REQUIRED: NO # DEFAULT: Etc/UTC # VALID OPTIONS: Any valid IANA TZ formatted timezone. Refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. -#TZ=Etc/UTC +TZ=Etc/UTC # GID: # You may wish to change the GroupID of the container's user. This allows it access certain resources on the host like certificates or files. @@ -27,25 +27,40 @@ # REQUIRED: NO # DEFAULT: # VALID OPTIONS: Any valid directory on the host -#WATCHDIR= +WATCHDIR=~/myWebProject + # # AB-NGINX parameters # refer to https://git.asifbacchus.dev/ab-docker/ab-nginx/wiki for more details +# NGINX_HTTP: +# Port to map on the host for ab-nginx to listen for HTTP connections. +# REQUIRED: NO +# DEFAULT: 80 +# VALID OPTIONS: Any valid TCP port that does not cause conflicts in your environment +#NGINX_HTTP=80 + +# NGINX_HTTPS: +# Port to map on the host for ab-nginx to listen for HTTPS connections. +# REQUIRED: NO +# DEFAULT: 443 +# VALID OPTIONS: Any valid TCP port that does not cause conflicts in your environment +#NGINX_HTTPS=443 + # SERVER_NAMES: # Space-delimited list of names to which the server should respond. This needs to match any certificates being used. # REQUIRED: NO # DEFAULT: _ # VALID OPTIONS: Any valid hostnames for your environment -#SERVER_NAMES=_ +SERVER_NAMES=_ # TLS13_ONLY: # Use and accept only TLS version 1.3 connections. If false, both TLS versions 1.2 and 1.3 will be accepted. # REQUIRED: NO # DEFAULT: TRUE # VALID OPTIONS: TRUE, FALSE -#TLS13_ONLY=TRUE +TLS13_ONLY=TRUE # @@ -63,42 +78,42 @@ # REQUIRED: NO # DEFAULT: "html,xml,css,js,jsx,ts,tsx,php,py" # VALID OPTIONS: Any valid file extension(s) -#LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py" +LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py" # LR_EXCLUDE: # Comma-delimited list of files/directories to exclude from monitoring. This list *must* be quoted. # REQUIRED: NO # DEFAULT: ".git/,.svn/,.vscode/,.idea/" # VALID OPTIONS: Any valid files or directories/ -#LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/" +LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/" # LR_DELAY: # Amount of time in milliseconds before detecting a change and sending a trigger for a browser reload. Useful if you need to allow time for background recompilation, etc. # REQUIRED: NO # DEFAULT: 500 # VALID OPTIONS: Any integer representing a number of milliseconds (ms) -#LR_DELAY=500 +LR_DELAY=500 # LR_DEBUG: # Whether or not to print diagnostic debugging messages about the server's operation. Usually a good idea to leave this set to 'true'. # REQUIRED: NO # DEFAULT: true # VALID OPTIONS: true, false -#LR_DEBUG=true +LR_DEBUG=true # LR_HTTPS: # Whether or not to enable SSL/TLS on the server's listening port. This may be required depending on your domain and environment configuration. # REQUIRED: NO # DEFAULT: true # VALID OPTIONS: true, false -#LR_HTTPS=true +LR_HTTPS=true # CERT_HOSTNAME: # Hostname to use if container is auto-generating a self-signed certificate. # REQUIRED: NO # DEFAULT: $HOSTNAME # VALID OPTIONS: Any valid hostname -#CERT_HOSTNAME=$HOSTNAME +CERT_HOSTNAME=${SERVER_NAMES} #EOF diff --git a/docker-compose.yml b/docker-compose.yml index a3c2809..1b25a11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,9 +13,12 @@ services: - ${WATCHDIR}:/usr/share/nginx/html:ro - ./nginx/config:/etc/nginx/config:ro ports: - - "8080:80" - - "8443:443" - env_file: livereload.params + - "${NGINX_HTTP:-80}:80" + - "${NGINX_HTTPS:-443}:443" + environment: + - TZ=${TZ} + - SERVER_NAMES=${SERVER_NAMES} + - TLS13_ONLY=${TLS13_ONLY} user: "8080:${GID:-8080}" livereload: image: docker.asifbacchus.dev/livereload/livereload:latest @@ -24,8 +27,16 @@ services: - ./certs:certs:ro - ${WATCHDIR}:/watch:ro ports: - - "35729:35729" - env_file: livereload.params + - "${LR_PORT:-35729}:${LR_PORT:-35729}" + environment: + - TZ=${TZ} + - LR_PORT=${LR_PORT} + - LR_EXTS=${LR_EXTS} + - LR_EXCLUDE=${LR_EXCLUDE} + - LR_DELAY=${LR_DELAY} + - LR_DEBUG=${LR_DEBUG} + - LR_HTTPS=${LR_HTTPS} + - CERT_HOSTNAME=${CERT_HOSTNAME} user: "9999:${GID:-9999}" command: listen