Allow specifying a config.json filename in dindctl

This is necessary to run several supervisors as they can't share a config

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-10-10 10:21:21 -07:00
parent 5d88961b34
commit 6ac6f0c308
2 changed files with 11 additions and 2 deletions

View File

@ -30,6 +30,7 @@
# * SUPERVISOR_EXTRA_MOUNTS: Additional bind mount flags for the docker-in-docker supervisor
# * PASSWORDLESS_DROPBEAR: For run-supervisor - start a passwordless ssh daemon in the docker-in-docker supervisor
# * CONTAINER_NAME: For run-supervisor, specify the container name for the docker-in-docker container (default: resin_supervisor_1)
# * CONFIG_FILENAME: For run-supervisor, specify the filename to mount as config.json, relative to tools/dind/ (default: config.json)
#
THIS_FILE := $(lastword $(MAKEFILE_LIST))
@ -78,9 +79,10 @@ IMAGE ?= resin/$(ARCH)-supervisor:master
SUPERVISOR_IMAGE ?= resin/$(ARCH)-supervisor:master
PASSWORDLESS_DROPBEAR ?= false
CONTAINER_NAME ?= resin_supervisor_1
CONFIG_FILENAME ?= config.json
# Bind mounts and variables for the run-supervisor target
SUPERVISOR_DIND_MOUNTS := -v $$(pwd)/../../:/resin-supervisor -v $$(pwd)/config.json:/mnt/conf/config.json -v $$(pwd)/config/env:/usr/src/app/config/env -v $$(pwd)/config/localenv:/usr/src/app/config/localenv
SUPERVISOR_DIND_MOUNTS := -v $$(pwd)/../../:/resin-supervisor -v $$(pwd)/$(CONFIG_FILENAME):/mnt/conf/config.json -v $$(pwd)/config/env:/usr/src/app/config/env -v $$(pwd)/config/localenv:/usr/src/app/config/localenv
ifeq ($(OS), Linux)
SUPERVISOR_DIND_MOUNTS := ${SUPERVISOR_DIND_MOUNTS} -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /bin/kmod:/bin/kmod
endif

View File

@ -24,8 +24,9 @@
# --dind-container [name] container name for the dind host container ( default: resin_supervisor_1 )
# --mount-dist bind-mount './dist/' (where webpack stores the built js) from local development environment into supervisor container.
# --mount-nm bind-mount './node_modules/' from local development environment into supervisor container.
# --preload | -p use tools/dev/apps.json to preload an application image into the dind host.
# --preload | -p use tools/dev/apps.json to preload an application image into the dind host.
# --ssh enable a passwordless dropbear ssh server on the dind host
# --config | -c [file] path to config.json, relative to tools/dind ( default: config.json )
#
# See README.md for examples.
#
@ -49,6 +50,7 @@ DIND_IMAGE="resin-supervisor-dind"
CONTAINER_NAME="resin_supervisor_1"
PRELOADED_IMAGE=""
OPTIMIZE="true"
CONFIG_FILENAME="config.json"
function showHelp {
cat $THIS_FILE | awk '{if(/^#/)print;else exit}' | tail -n +2 | sed 's/\#//' | sed 's|dindctl|'$THIS_FILE'|'
@ -75,6 +77,10 @@ function parseOptions {
SUPERVISOR_IMAGE="$2"
shift || { echo "--image provided not specified" && exit 1; }
;;
-c|--config)
CONFIG_FILENAME="$2"
shift || { echo "--config provided not specified" && exit 1; }
;;
--dind-image)
DIND_IMAGE="$2"
shift || { echo "--dind-image provided not specified" && exit 1; }
@ -143,6 +149,7 @@ function runDind {
PRELOADED_IMAGE="$PRELOADED_IMAGE" \
IMAGE="$DIND_IMAGE" \
CONTAINER_NAME="$CONTAINER_NAME" \
CONFIG_FILENAME="$CONFIG_FILENAME" \
run-supervisor
}