From e4569d790b52ec47d6906230ac51fe3588c305c1 Mon Sep 17 00:00:00 2001 From: ojizero Date: Sun, 25 Feb 2018 12:43:16 +0200 Subject: [PATCH 1/3] added APP_USER env variable to control running user --- command-runner/Dockerfile | 9 ++++++++- command-runner/README.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/command-runner/Dockerfile b/command-runner/Dockerfile index 9642336..9e2980c 100644 --- a/command-runner/Dockerfile +++ b/command-runner/Dockerfile @@ -7,10 +7,14 @@ FROM ${RUNNER}:${TAG} LABEL maintainer='Ameer A. ' +USER root + ENV STAGE 'development' ENV NODE_ENV ${STAGE} -ENV APP_DIR '/opt/app' +ENV APP_DIR '/opt/app' +ENV APP_USER 'root' + ENV CRON_SPEC '* * * * *' ENV CRON_EXEC '' ENV EXEC_OPTS '' @@ -25,4 +29,7 @@ ADD scripts . RUN chmod +x * RUN ./cron-installer.sh +USER ${APP_USER} +WORKDIR ${APP_DIR} + CMD [ "/opt/scripts/runner-cmd.sh" ] diff --git a/command-runner/README.md b/command-runner/README.md index 95f2059..e2fccc4 100644 --- a/command-runner/README.md +++ b/command-runner/README.md @@ -13,6 +13,7 @@ Manages running our Node based CRON jobs. `STAGE`: The stage of the running CRON, if it's not `prod` or `production` the command is run only once. Default value `development`. `APP_DIR`: The directory inside the container to run the command in. Default value `/opt/app`. +`APP_USER`: The user inside the container to run the command in. Default value `root`. `CRON_SPEC`: The schedule for the CRON, using the standard CRON notation. Default value `* * * * *`. `CRON_EXEC`: The command to be executed on the schedule, it has to be provided otherwise an error is thrown when running the image. `EXEC_OPTS`: Any addition options the command needs. Default value is empty. From e64b6d24b4c057418f61a5c3fe88b7da37b3ec48 Mon Sep 17 00:00:00 2001 From: ojizero Date: Sun, 25 Feb 2018 13:01:05 +0200 Subject: [PATCH 2/3] correct runner name when it contains a namespace --- command-runner/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command-runner/Makefile b/command-runner/Makefile index fd72073..0145c40 100644 --- a/command-runner/Makefile +++ b/command-runner/Makefile @@ -3,7 +3,7 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) RUNNER ?= node BASE_TAG ?= latest -IMAGE_REPO ?= $(RUNNER)-runner +IMAGE_REPO ?= $(shell basename $(RUNNER))-runner IMAGE_TAG ?= $(BASE_TAG) NAMESPACE ?= yamsafer From b46e4ec84ffd5d3911ff6b0d9336f35471559c51 Mon Sep 17 00:00:00 2001 From: ojizero Date: Mon, 26 Feb 2018 10:43:08 +0200 Subject: [PATCH 3/3] add Gawk to packages to install --- command-runner/scripts/cron-installer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command-runner/scripts/cron-installer.sh b/command-runner/scripts/cron-installer.sh index 19719c3..4d241b9 100644 --- a/command-runner/scripts/cron-installer.sh +++ b/command-runner/scripts/cron-installer.sh @@ -17,7 +17,7 @@ if [ $(which apt-get) ]; then INSTALL_COMMAND='install' INSTALL_OPTS='-y' - PACKAGES='cron' + PACKAGES='cron gawk' elif [ $(which apk) ]; then PACKAGE_MANAGER='apk' @@ -27,7 +27,7 @@ elif [ $(which apk) ]; then INSTALL_COMMAND='add' INSTALL_OPTS='' - PACKAGES='dcron' + PACKAGES='dcron gawk' ALP_CLR='-e' else