mirror of
https://github.com/spikecodes/libreddit
synced 2024-12-26 18:45:39 +01:00
42 lines
1.5 KiB
Docker
42 lines
1.5 KiB
Docker
####################################################################################################
|
|
## Builder
|
|
####################################################################################################
|
|
FROM rust:alpine AS builder
|
|
|
|
RUN apk add --no-cache g++ git
|
|
|
|
WORKDIR /usr/src/libreddit
|
|
|
|
COPY . .
|
|
|
|
# net.git-fetch-with-cli is specified in order to prevent a potential OOM kill
|
|
# in low memory environments. See:
|
|
# https://users.rust-lang.org/t/cargo-uses-too-much-memory-being-run-in-qemu/76531
|
|
# This is tracked under issue #641. This also requires us to install git in the
|
|
# builder.
|
|
RUN cargo install --config net.git-fetch-with-cli=true --path .
|
|
|
|
####################################################################################################
|
|
## Final image
|
|
####################################################################################################
|
|
FROM alpine:latest
|
|
|
|
# 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
|
|
COPY --from=builder /usr/local/cargo/bin/libreddit /usr/local/bin/libreddit
|
|
|
|
# Use an unprivileged user.
|
|
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
|
|
USER libreddit
|
|
|
|
# Tell Docker to expose port 8080
|
|
EXPOSE 8080
|
|
|
|
# Run a healthcheck every minute to make sure Libreddit is functional
|
|
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
|
|
|
|
CMD ["libreddit"]
|