diff --git a/Dockerfile b/Dockerfile index 7f72aaa..e5fb894 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,10 @@ # STEP 1 build executable binary ############################ FROM golang:alpine AS builder -# Install git. -# Git is required for fetching the dependencies. -RUN apk update && apk add --no-cache git gcc libc-dev openssl && go get -u github.com/gobuffalo/packr/packr +RUN apk update && apk add --no-cache git gcc libc-dev openssl && go install github.com/gobuffalo/packr/packr@latest WORKDIR $GOPATH/src/securitybunker/databunker/src/ COPY src/go.mod ./deps RUN cat ./deps | grep -v storage > ./go.mod && go mod download - COPY . $GOPATH/src/securitybunker/databunker/ #RUN echo "tidy " && go get -u && go mod tidy && cat ./go.mod # Fetch dependencies. @@ -21,12 +18,9 @@ RUN go get -d -v && \ # STEP 2 build a small image ############################ FROM scratch -# Copy our static executable. -COPY --from=builder /bin/busybox /bin/sh -COPY --from=builder /bin/busybox /usr/bin/openssl /bin/ +COPY --from=builder /bin/sh /bin/busybox /usr/bin/openssl /bin/ COPY --from=builder /lib/ld* /lib/libssl.* /lib/libcrypto.* /lib/ -COPY --from=builder /etc/group /etc/ -COPY --from=builder /etc/ssl /etc/ssl +COPY --from=builder /etc/group etc/ssl /etc/ COPY databunker.yaml /databunker/conf/ RUN /bin/busybox mkdir -p /databunker/data && \ /bin/busybox mkdir -p /databunker/certs && \ @@ -38,10 +32,8 @@ RUN /bin/busybox mkdir -p /databunker/data && \ /bin/busybox chmod 0777 /tmp && \ addgroup -S appgroup && adduser --no-create-home -S appuser -G appgroup && \ chown appuser:appgroup /databunker/data -# Tell docker that all future commands should run as the appuser user USER appuser -COPY --from=builder /go/bin/databunker /databunker/bin/databunker -COPY run.sh health-check.sh /databunker/bin/ +COPY --from=builder /go/bin/databunker $GOPATH/src/securitybunker/databunker/{run.sh,health-check.sh} /databunker/bin/ EXPOSE 3000 HEALTHCHECK --interval=5s --timeout=3s --start-period=33s --retries=3 CMD /databunker/bin/health-check.sh ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"]