redsunlib/Dockerfile

34 lines
826 B
Docker
Raw Normal View History

2024-04-09 22:19:40 +12:00
## Builder
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
FROM rust:alpine AS builder
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
RUN apk add --no-cache musl-dev
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
WORKDIR /redlib
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
COPY . .
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
RUN cargo build --target x86_64-unknown-linux-musl --release
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
## Final image
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
FROM alpine:latest
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +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
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
# Copy our build
COPY --from=builder /redlib/target/x86_64-unknown-linux-musl/release/redlib /usr/local/bin/redlib
2024-04-09 00:39:22 +12:00
2024-04-09 22:19:40 +12:00
# Use an unprivileged user.
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
2024-04-09 00:39:22 +12:00
USER redlib
2024-04-09 22:19:40 +12:00
# Tell Docker to expose port 8080
2024-04-09 00:39:22 +12:00
EXPOSE 8080
# Run a healthcheck every minute to make sure redlib is functional
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
2024-04-09 22:19:40 +12:00
CMD ["redlib"]