From 317e285911b22269bb395ac2fa2b475bb5928364 Mon Sep 17 00:00:00 2001 From: sinkingpoint Date: Mon, 11 Jul 2022 21:26:44 +1000 Subject: [PATCH] Clean up docker file This commit fixes up the Dockerfile to make it a bit cleaner and remove some cruft --- .dockerignore | 1 + Dockerfile | 36 ++++++++---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index df48684..5b550e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,15 @@ FROM ekidd/rust-musl-builder:stable as builder - -WORKDIR /usr/src/app - -COPY . . - -RUN cargo install --path . - +ADD --chown=rust:rust . ./ +RUN cargo build --release FROM alpine:latest as runner - -ARG APP=/usr/src/app - -ENV TZ=Etc/UTC \ - APP_USER=appuser - -RUN addgroup -S $APP_USER \ - && adduser -S -g $APP_USER $APP_USER - -RUN apk add --no-cache ca-certificates tzdata - -WORKDIR ${APP} - -COPY --from=builder ${APP}/target/x86_64-unknown-linux-musl/release/gravel-gateway . - -RUN chown -R $APP_USER:$APP_USER ${APP} - +ARG APP_USER=gravel +RUN addgroup -S $APP_USER && adduser -S -g $APP_USER $APP_USER +COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/gravel-gateway /usr/bin/gravel-gateway +RUN chown -R $APP_USER:$APP_USER /usr/bin/gravel-gateway USER $APP_USER - EXPOSE 4278 -ENTRYPOINT [ "./gravel-gateway", "-l", "0.0.0.0:4278" ] +ENTRYPOINT [ "/usr/bin/gravel-gateway", "-l", "0.0.0.0:4278" ] -HEALTHCHECK --interval=30s --timeout=3s \ - CMD wget --spider localhost:4278/metrics +HEALTHCHECK --interval=30s --timeout=3s CMD wget --spider localhost:4278/metrics