From e2ec6aee768d0ed0ed2ffc5bf5f3f7f2df32af2c Mon Sep 17 00:00:00 2001 From: khartmann Date: Mon, 9 Dec 2019 12:48:21 -0500 Subject: [PATCH 1/3] Bugfix: sing now computes it's parent directory correctly Enhancement: docker client now runs as a song user that has the sing binary in the PATH environment variable --- Dockerfile | 5 +++-- song-client/src/main/bin/sing | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1de5ea87..76bce0036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,10 @@ FROM openjdk:11-jre-stretch as client ENV SONG_CLIENT_HOME /song-client ENV CLIENT_DIST_DIR /song-client-dist - -ENV TARBALL $DCC_HOME/download.tar.gz +ENV PATH /usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SONG_CLIENT_HOME/bin COPY --from=builder /srv/song-client/target/song-client-*-dist.tar.gz /song-client.tar.gz +RUN groupadd -r song && useradd -r -g song song RUN tar zxvf song-client.tar.gz -C /tmp \ && rm -rf song-client.tar.gz \ @@ -27,6 +27,7 @@ RUN tar zxvf song-client.tar.gz -C /tmp \ # Set working directory for convenience with interactive usage WORKDIR $SONG_CLIENT_HOME +USER song ############################################################################################################### diff --git a/song-client/src/main/bin/sing b/song-client/src/main/bin/sing index cbd6ece6c..aa8256d29 100755 --- a/song-client/src/main/bin/sing +++ b/song-client/src/main/bin/sing @@ -29,7 +29,7 @@ elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then # echo Found Java in JAVA_HOME _java="$JAVA_HOME/bin/java" else - echo "Java not found. Sing requires JDK 1.8" + echo "Java not found. Sing requires Java 11." exit 1 fi @@ -42,10 +42,8 @@ if [[ "$_java" ]]; then fi fi -current_dir=$PWD -fn=$0 -sing_home=$current_dir/`dirname $fn`/../ - +here=$(dirname $0) +sing_home=${here%/bin} # -Dspring.config.location="$sing_home/conf/" \ java --illegal-access=deny \ From 070e498a80f498175bbdb00be85dd827efb3615b Mon Sep 17 00:00:00 2001 From: khartmann Date: Mon, 9 Dec 2019 16:05:26 -0500 Subject: [PATCH 2/3] PER PR --- .env | 2 -- Dockerfile | 2 -- Dockerfile.dev | 1 + docker-compose.yml | 2 ++ docker/tools/score-client-demo | 2 +- docker/tools/score-client-dev | 2 +- docker/tools/song-client-demo | 2 +- docker/tools/song-client-dev | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index f3a17455e..000000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -COMPOSE_PROJECT_NAME=song - diff --git a/Dockerfile b/Dockerfile index 76bce0036..c09a81a98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ ENV CLIENT_DIST_DIR /song-client-dist ENV PATH /usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SONG_CLIENT_HOME/bin COPY --from=builder /srv/song-client/target/song-client-*-dist.tar.gz /song-client.tar.gz -RUN groupadd -r song && useradd -r -g song song RUN tar zxvf song-client.tar.gz -C /tmp \ && rm -rf song-client.tar.gz \ @@ -27,7 +26,6 @@ RUN tar zxvf song-client.tar.gz -C /tmp \ # Set working directory for convenience with interactive usage WORKDIR $SONG_CLIENT_HOME -USER song ############################################################################################################### diff --git a/Dockerfile.dev b/Dockerfile.dev index 8939cc2ee..c1ee811be 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -5,6 +5,7 @@ FROM openjdk:11-jre-stretch as client ENV SONG_CLIENT_HOME /song-client ENV CLIENT_DIST_DIR /song-client-dist +ENV PATH /usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SONG_CLIENT_HOME/bin COPY song-client/target/song-client-*-dist.tar.gz /song-client.tar.gz RUN tar zxvf song-client.tar.gz -C /tmp \ diff --git a/docker-compose.yml b/docker-compose.yml index 491c88c6f..24401dd15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,6 +89,7 @@ services: - "./docker/scratch/score-client-logs:/score-client/logs" - "./docker/scratch/song-client-output:/song-client/output" command: bin/score-client + user: "$MY_UID:$MY_GID" song-db: image: "postgres:9.6" environment: @@ -123,6 +124,7 @@ services: - "./docker/scratch/song-client-logs:/song-client/logs" - "./docker/scratch/song-client-output:/song-client/output" command: bin/sing + user: "$MY_UID:$MY_GID" song-server: build: context: ./ diff --git a/docker/tools/score-client-demo b/docker/tools/score-client-demo index c033e261d..6bce5dad6 100755 --- a/docker/tools/score-client-demo +++ b/docker/tools/score-client-demo @@ -6,4 +6,4 @@ BASH_SCRIPT_DIR=$( dirname "${BASH_SCRIPT}") DOCKERFILE_NAME=Dockerfile \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../../docker-compose.yml \ - run --rm score-client bin/score-client $@ + run --rm score-client score-client $@ diff --git a/docker/tools/score-client-dev b/docker/tools/score-client-dev index 7f294d5ab..8b43c3ada 100755 --- a/docker/tools/score-client-dev +++ b/docker/tools/score-client-dev @@ -6,4 +6,4 @@ BASH_SCRIPT_DIR=$( dirname "${BASH_SCRIPT}") DOCKERFILE_NAME=Dockerfile.dev \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../../docker-compose.yml \ - run --rm score-client bin/score-client $@ + run --rm score-client score-client $@ diff --git a/docker/tools/song-client-demo b/docker/tools/song-client-demo index d30d7af94..0e70ed3d8 100755 --- a/docker/tools/song-client-demo +++ b/docker/tools/song-client-demo @@ -8,4 +8,4 @@ DOCKERFILE_NAME=Dockerfile \ MY_GID=$(id -g) \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../../docker-compose.yml \ - run --rm song-client bin/sing $@ + run --rm song-client sing $@ diff --git a/docker/tools/song-client-dev b/docker/tools/song-client-dev index 6e5f9f1a2..6e179e667 100755 --- a/docker/tools/song-client-dev +++ b/docker/tools/song-client-dev @@ -8,4 +8,4 @@ DOCKERFILE_NAME=Dockerfile.dev \ MY_GID=$(id -g) \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../..//docker-compose.yml \ - run --rm song-client bin/sing $@ + run --rm song-client sing $@ From be2860d239725b7d802c6d0e8e1eeda318833732 Mon Sep 17 00:00:00 2001 From: khartmann Date: Tue, 10 Dec 2019 11:39:03 -0500 Subject: [PATCH 3/3] 1) Fixes as per PR 2) Bugfix: sed command wasn't generating correct analysisId. --- Makefile | 6 +++--- docker/tools/score-client-demo | 2 +- docker/tools/score-client-dev | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fb3af24e7..7b6250493 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ LOG_DIRS := $(SCORE_SERVER_LOGS_DIR) $(SCORE_CLIENT_LOGS_DIR) $(SONG_SERVER_LOGS DOCKER_COMPOSE_CMD := echo "*********** DEMO_MODE = $(DEMO_MODE) **************" \ && echo "*********** FORCE = $(FORCE) **************" \ && DOCKERFILE_NAME=$(DOCKERFILE_NAME) MY_UID=$(MY_UID) MY_GID=$(MY_GID) $(DOCKER_COMPOSE_EXE) -f $(ROOT_DIR)/docker-compose.yml -SONG_CLIENT_CMD := $(DOCKER_COMPOSE_CMD) run --rm -u $(THIS_USER) song-client bin/sing +SONG_CLIENT_CMD := $(DOCKER_COMPOSE_CMD) run --rm -u $(THIS_USER) song-client sing SCORE_CLIENT_CMD := $(DOCKER_COMPOSE_CMD) run --rm -u $(THIS_USER) score-client bin/score-client DC_UP_CMD := $(DOCKER_COMPOSE_CMD) up -d --build MVN_CMD := $(MVN_EXE) -f $(ROOT_DIR)/pom.xml @@ -238,8 +238,8 @@ get-analysis-id: test-submit: start-song-server _ping_song_server @echo $(YELLOW)$(INFO_HEADER) "Submitting payload /data/submit/exampleVariantCall.json" $(END) @$(SONG_CLIENT_CMD) submit -f /data/submit/exampleVariantCall.json | tee $(SONG_CLIENT_SUBMIT_RESPONSE_FILE) - @cat $(SONG_CLIENT_SUBMIT_RESPONSE_FILE) | grep analysisId | sed 's/.*://' | sed 's/"\|,//g' > $(SONG_CLIENT_ANALYSIS_ID_FILE) - @echo $(YELLOW)$(INFO_HEADER) "Successfully submitted. Cached analysisId: " $$($(GET_ANALYSIS_ID_CMD)) $(END) + @cat $(SONG_CLIENT_SUBMIT_RESPONSE_FILE) | grep analysisId | sed -e 's#.*:[^"]*"\([^"]*\)".*#\1#' > $(SONG_CLIENT_ANALYSIS_ID_FILE) + @echo $(YELLOW)$(INFO_HEADER) "Successfully submitted. Cached analysisId: '"$$($(GET_ANALYSIS_ID_CMD))"'" $(END) test-manifest: test-submit @echo $(YELLOW)$(INFO_HEADER) "Creating manifest at /song-client/output" $(END) diff --git a/docker/tools/score-client-demo b/docker/tools/score-client-demo index 6bce5dad6..c033e261d 100755 --- a/docker/tools/score-client-demo +++ b/docker/tools/score-client-demo @@ -6,4 +6,4 @@ BASH_SCRIPT_DIR=$( dirname "${BASH_SCRIPT}") DOCKERFILE_NAME=Dockerfile \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../../docker-compose.yml \ - run --rm score-client score-client $@ + run --rm score-client bin/score-client $@ diff --git a/docker/tools/score-client-dev b/docker/tools/score-client-dev index 8b43c3ada..7f294d5ab 100755 --- a/docker/tools/score-client-dev +++ b/docker/tools/score-client-dev @@ -6,4 +6,4 @@ BASH_SCRIPT_DIR=$( dirname "${BASH_SCRIPT}") DOCKERFILE_NAME=Dockerfile.dev \ docker-compose \ -f ${BASH_SCRIPT_DIR}/../../docker-compose.yml \ - run --rm score-client score-client $@ + run --rm score-client bin/score-client $@