From d7f53254443419e1c1e28908b56d16b46d57b781 Mon Sep 17 00:00:00 2001 From: Taka Date: Mon, 30 Mar 2020 00:55:28 +0000 Subject: [PATCH] Added a switch to specify which Docker network to use when building the container. --- docker-compose.yml | 11 +++++++---- run-containers.sh | 9 ++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c448577..f797e90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,24 @@ # IMPORTANT: Use run-containers.sh to set up the necessary environment variables. -version: "3" +version: "3.4" services: web: image: asl-articles-web:$TAG - build: web + build: + context: web + network: $BUILD_NETWORK ports: - - "$WEB_PORTNO:80" + - $WEB_PORTNO:80 flask: image: asl-articles-flask:$TAG build: context: . + network: $BUILD_NETWORK args: ENABLE_TESTS: $ENABLE_TESTS ports: - - "$FLASK_PORTNO:5000" + - $FLASK_PORTNO:5000 volumes: - $SQLITE:/data/sqlite.db - $EXTERNAL_DOCS_BASEDIR:/data/docs/ diff --git a/run-containers.sh b/run-containers.sh index d07895f..6e880dc 100755 --- a/run-containers.sh +++ b/run-containers.sh @@ -19,6 +19,7 @@ function print_help { echo " -r --aslrb Base URL for an eASLRB." echo " -a --author-aliases Author aliases config file (see config/author-aliases.cfg.example)." echo " --no-build Launch the containers as they are (i.e. without rebuilding them first)." + echo " --build-network Docker network to use when building the container." } # --------------------------------------------------------------------- @@ -36,13 +37,14 @@ export ASLRB_BASE_URL= export AUTHOR_ALIASES= export ENABLE_TESTS= NO_BUILD= +export BUILD_NETWORK= # parse the command-line arguments if [ $# -eq 0 ]; then print_help exit 0 fi -params="$(getopt -o t:d:e:u:r:a:h -l tag:,dbconn:,web-portno:,flask-portno:,extdocs:,user-files:,aslrb:,author-aliases:,no-build,help --name "$0" -- "$@")" +params="$(getopt -o t:d:e:u:r:a:h -l tag:,dbconn:,web-portno:,flask-portno:,extdocs:,user-files:,aslrb:,author-aliases:,no-build,build-network:,help --name "$0" -- "$@")" if [ $? -ne 0 ]; then exit 1; fi eval set -- "$params" while true; do @@ -74,6 +76,11 @@ while true; do --no-build ) NO_BUILD=1 shift 1 ;; + --build-network ) + # FUDGE! We sometimes can't get out to the internet from the container (DNS problems) using the default + # "bridge" network, so we offer the option of using an alternate network (e.g. "host"). + BUILD_NETWORK=$2 + shift 2 ;; -h | --help ) print_help exit 0 ;;