diff --git a/docker-images/unlynx/Dockerfile b/docker-images/unlynx/Dockerfile index 94d4e62..4179d14 100644 --- a/docker-images/unlynx/Dockerfile +++ b/docker-images/unlynx/Dockerfile @@ -1,44 +1,41 @@ FROM golang:1.9 -# environment variables -ENV UNLYNX_REPO="github.com/lca1/medco" \ - UNLYNX_REPO_BRANCH="master" \ - CONF_DIR="/opt/medco-configuration" +# build time environment variables +ENV UNLYNX_REPO="github.com/lca1/unlynx" \ + UNLYNX_VERSION="MedCo_v0.1" \ + MEDCO_CONF_DIR="/medco-configuration" # get maximum of dependencies and cache them RUN go get -v -d gopkg.in/dedis/onet.v1/... && \ go get -v -d gopkg.in/dedis/crypto.v0/... && \ go get -v -d gopkg.in/urfave/cli.v1/... && \ go get -v -d github.com/Knetic/govaluate/... && \ go get -v -d github.com/btcsuite/goleveldb/... && \ go get -v -d github.com/r0fls/gostats/... && \ go get -v -d github.com/fanliao/go-concurrentMap/... && \ - go get -v -d github.com/lib/pq/... && \ - go get -v -d github.com/lca1/unlynx/... + go get -v -d github.com/lib/pq/... # get sources and switch branch WORKDIR /go/src/$UNLYNX_REPO -RUN git clone https://$UNLYNX_REPO.git . && \ - git checkout $UNLYNX_REPO_BRANCH +RUN git clone --depth 1 --branch $UNLYNX_VERSION https://$UNLYNX_REPO.git . -# get remaining dependencies, compile and install unlynxMedCo binary, and make it available in the shared folder +# get remaining dependencies, compile and install unlynxMedCo binary WORKDIR app RUN go get -v -d ./... && \ go install -v ./... # add script that copies the binary in the configuration folder -COPY copy-unlynx-binary.sh / +COPY copy-unlynx-binary.sh docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/copy-unlynx-binary.sh /usr/local/bin/docker-entrypoint.sh -# conf and run -ARG NODE_IDX_ARG="0" -ARG UNLYNX_DEBUG_LEVEL_ARG="1" -ENV NODE_IDX="$NODE_IDX_ARG" \ - UNLYNX_BIN_EXPORT_PATH="$CONF_DIR/unlynxMedCo" \ - UNLYNX_DEBUG_LEVEL="$UNLYNX_DEBUG_LEVEL_ARG" -ENV UNLYNX_KEY_FILE_PATH="$CONF_DIR/srv$NODE_IDX-private.toml" \ - UNLYNX_DDT_SECRETS_FILE_PATH="$CONF_DIR/srv$NODE_IDX-ddtsecrets.toml" +# run time environment variables +ENV NODE_IDX="0" \ + UNLYNX_DEBUG_LEVEL="1" \ + UNLYNX_BIN_EXPORT_PATH="$MEDCO_CONF_DIR/unlynxMedCo" +ENV UNLYNX_KEY_FILE_PATH="$MEDCO_CONF_DIR/srv$NODE_IDX-private.toml" \ + UNLYNX_DDT_SECRETS_FILE_PATH="$MEDCO_CONF_DIR/srv$NODE_IDX-ddtsecrets.toml" EXPOSE 2000 2001 -VOLUME "$CONF_DIR" -WORKDIR "$CONF_DIR" -ENTRYPOINT ["sh", "-c", "sh /copy-unlynx-binary.sh && $UNLYNX_BIN_EXPORT_PATH -d $UNLYNX_DEBUG_LEVEL server -c $UNLYNX_KEY_FILE_PATH"] +VOLUME "$MEDCO_CONF_DIR" +WORKDIR "$MEDCO_CONF_DIR" +ENTRYPOINT docker-entrypoint.sh diff --git a/docker-images/unlynx/copy-unlynx-binary.sh b/docker-images/unlynx/copy-unlynx-binary.sh index 9ba639d..1a3bf40 100644 --- a/docker-images/unlynx/copy-unlynx-binary.sh +++ b/docker-images/unlynx/copy-unlynx-binary.sh @@ -1,7 +1,7 @@ #!/bin/bash -set -e +set -Eeuo pipefail # copy unlynx binary in the configuration folder (environment variables are available) rm -f $UNLYNX_BIN_EXPORT_PATH -cp -a $(which app) $UNLYNX_BIN_EXPORT_PATH +cp -a /go/bin/unlynxMedCo $UNLYNX_BIN_EXPORT_PATH chmod 777 $UNLYNX_BIN_EXPORT_PATH diff --git a/docker-images/unlynx/docker-entrypoint.sh b/docker-images/unlynx/docker-entrypoint.sh new file mode 100644 index 0000000..a95403c --- /dev/null +++ b/docker-images/unlynx/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +copy-unlynx-binary.sh +exec $UNLYNX_BIN_EXPORT_PATH -d $UNLYNX_DEBUG_LEVEL server -c $UNLYNX_KEY_FILE_PATH