From b19486fed5090c5be6df1b707ddf2f2aab7e360b Mon Sep 17 00:00:00 2001 From: stremovsky Date: Sun, 15 Dec 2019 09:27:00 +0200 Subject: [PATCH] 2nd version of docker project --- Dockerfile | 14 +++++++++----- run.sh | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4467a2e..a9f9331 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,17 +27,21 @@ RUN packr RUN go build -o /go/bin/databunker # clean packr RUN packr clean -RUN cp ../run.sh /go/bin/databunker.sh ############################ # STEP 2 build a small image ############################ FROM scratch # Copy our static executable. -COPY --from=builder /bin/sh /bin/sh +COPY --from=builder /bin/busybox /bin/busybox +COPY --from=builder /bin/busybox /bin/sh COPY --from=builder /lib/ld* /lib/ -COPY --from=builder /go/bin/databunker /go/bin/databunker -COPY --from=builder /go/bin/databunker.sh /go/bin/databunker.sh +COPY --from=builder /go/bin/databunker /databunker/bin/databunker +COPY run.sh /databunker/bin/run.sh +COPY databunker.yaml /databunker/conf/ +RUN /bin/busybox mkdir -p /databunker/data +RUN /bin/busybox mkdir -p /databunker/certs +#RUN /bin/busybox ln -s /bin/busybox /bin/sh # Run the hello binary. #ENTRYPOINT ["/go/bin/databunker"] -ENTRYPOINT ["/bin/sh", "/go/bin/databunker.sh"] +ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"] #CMD ["/bin/sh", "-x", "-c", "/go/bin/databunker -init"] diff --git a/run.sh b/run.sh index c78af98..b17b656 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,18 @@ #!/bin/sh -echo "-------------INIT------------" -/go/bin/databunker -init -ls -al /go/bin/ +/bin/busybox find / + +DATABUNKER_MASTERKEY= +if [ ! -f /databunker/data/databunker.db ]; then + echo "-------------INIT------------" + /bin/busybox mkdir -p /tmp + RESULT=`/databunker/bin/databunker -init > /tmp/init.txt` + echo $RESULT + ROOT_TOKEN=`/bin/busybox awk '/API Root token:/ {print $4}' /tmp/init.txt` + MASTER_KEY=`/bin/busybox awk '/Master key:/ {print $3}' /tmp/init.txt` + echo "DATABUNKER_ROOTTOKEN $ROOT_TOKEN" + echo "DATABUNKER_MASTERKEY $MASTER_KEY" + /bin/busybox rm -rf /tmp/init.txt +fi echo "-------------RUN-------------" -/go/bin/databunker \ No newline at end of file +#/go/bin/databunker \ No newline at end of file