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-06-02 21:30:48 +12:00
|
|
|
RUN apk add --no-cache musl-dev git
|
2024-04-09 00:39:22 +12:00
|
|
|
|
2024-06-05 10:38:15 +12:00
|
|
|
WORKDIR /redsunlib
|
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
|
2024-06-05 10:38:15 +12:00
|
|
|
COPY --from=builder /redsunlib/target/x86_64-unknown-linux-musl/release/redsunlib /usr/local/bin/redsunlib
|
2024-04-09 00:39:22 +12:00
|
|
|
|
2024-04-09 22:19:40 +12:00
|
|
|
# Use an unprivileged user.
|
2024-06-05 10:38:15 +12:00
|
|
|
RUN adduser --home /nonexistent --no-create-home --disabled-password redsunlib
|
|
|
|
USER redsunlib
|
2024-04-09 00:39:22 +12:00
|
|
|
|
2024-04-09 22:19:40 +12:00
|
|
|
# Tell Docker to expose port 8080
|
2024-04-09 00:39:22 +12:00
|
|
|
EXPOSE 8080
|
|
|
|
|
2024-06-05 10:38:15 +12:00
|
|
|
# Run a healthcheck every minute to make sure redsunlib is functional
|
2024-06-01 00:02:08 +12:00
|
|
|
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
|
2024-04-09 00:39:22 +12:00
|
|
|
|
2024-06-05 10:38:15 +12:00
|
|
|
CMD ["redsunlib"]
|