redsunlib/Dockerfile

36 lines
1.2 KiB
Docker
Raw Normal View History

2021-04-10 10:24:47 +12:00
####################################################################################################
## Builder
####################################################################################################
2021-04-10 17:38:13 +12:00
FROM rust:alpine AS builder
2021-04-10 10:24:47 +12:00
2021-04-10 17:38:13 +12:00
RUN apk add --no-cache musl-dev
2021-04-10 10:24:47 +12:00
2023-12-27 12:25:52 +13:00
WORKDIR /redlib
2021-04-10 10:24:47 +12:00
2020-10-26 09:48:44 +13:00
COPY . .
2021-04-10 10:24:47 +12:00
RUN cargo build --target x86_64-unknown-linux-musl --release
####################################################################################################
## Final image
####################################################################################################
2021-04-10 17:38:13 +12:00
FROM alpine:latest
2021-04-10 10:24:47 +12:00
# Import ca-certificates from builder
COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Copy our build
2023-12-27 12:25:52 +13:00
COPY --from=builder /redlib/target/x86_64-unknown-linux-musl/release/redlib /usr/local/bin/redlib
2021-04-10 10:24:47 +12:00
# Use an unprivileged user.
2023-12-27 12:25:52 +13:00
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
USER redlib
2021-04-10 10:24:47 +12:00
# Tell Docker to expose port 8080
EXPOSE 8080
2021-04-10 10:24:47 +12:00
2023-12-27 12:25:52 +13:00
# Run a healthcheck every minute to make sure redlib is functional
2021-04-10 17:38:13 +12:00
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
2021-04-02 08:09:08 +13:00
2023-12-27 12:25:52 +13:00
CMD ["redlib"]