2021-04-10 00:24:47 +02:00
|
|
|
####################################################################################################
|
|
|
|
## Builder
|
|
|
|
####################################################################################################
|
2021-04-10 07:38:13 +02:00
|
|
|
FROM rust:alpine AS builder
|
2021-04-10 00:24:47 +02:00
|
|
|
|
2021-04-10 07:38:13 +02:00
|
|
|
RUN apk add --no-cache musl-dev
|
2021-04-10 00:24:47 +02:00
|
|
|
|
2021-04-10 07:38:13 +02:00
|
|
|
WORKDIR /libreddit
|
2021-04-10 00:24:47 +02:00
|
|
|
|
2020-10-25 21:48:44 +01:00
|
|
|
COPY . .
|
|
|
|
|
2021-04-10 00:24:47 +02:00
|
|
|
RUN cargo build --target x86_64-unknown-linux-musl --release
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
## Final image
|
|
|
|
####################################################################################################
|
2021-04-10 07:38:13 +02:00
|
|
|
FROM alpine:latest
|
2021-04-10 00:24:47 +02: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
|
2021-04-10 07:38:13 +02:00
|
|
|
COPY --from=builder /libreddit/target/x86_64-unknown-linux-musl/release/libreddit /usr/local/bin/libreddit
|
2021-04-10 00:24:47 +02:00
|
|
|
|
|
|
|
# Use an unprivileged user.
|
2021-04-10 07:38:13 +02:00
|
|
|
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
|
2021-04-01 21:09:08 +02:00
|
|
|
USER libreddit
|
2021-04-10 00:24:47 +02:00
|
|
|
|
|
|
|
# Tell Docker to expose port 8080
|
2021-02-24 20:17:36 +01:00
|
|
|
EXPOSE 8080
|
2021-04-10 00:24:47 +02:00
|
|
|
|
|
|
|
# Run a healthcheck every minute to make sure Libreddit is functional
|
2021-04-10 07:38:13 +02:00
|
|
|
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
|
2021-04-01 21:09:08 +02:00
|
|
|
|
2021-03-31 22:05:22 +02:00
|
|
|
CMD ["libreddit"]
|