2021-04-10 10:50:43 +12:00
|
|
|
####################################################################################################
|
|
|
|
## Builder
|
|
|
|
####################################################################################################
|
2021-04-10 13:59:04 +12:00
|
|
|
FROM rust:alpine AS builder
|
2021-04-10 10:50:43 +12:00
|
|
|
|
2021-04-10 13:59:04 +12:00
|
|
|
RUN apk add --no-cache g++
|
2021-04-10 10:50:43 +12:00
|
|
|
|
|
|
|
WORKDIR /usr/src/libreddit
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
2021-04-10 13:59:04 +12:00
|
|
|
RUN cargo install --path .
|
2021-04-10 10:50:43 +12:00
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
## Final image
|
|
|
|
####################################################################################################
|
2021-04-10 13:59:04 +12:00
|
|
|
FROM alpine:latest
|
2021-04-10 10:50:43 +12:00
|
|
|
|
2021-04-15 16:50:03 +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
|
|
|
|
|
2021-04-10 10:50:43 +12:00
|
|
|
# Copy our build
|
2021-04-10 13:59:04 +12:00
|
|
|
COPY --from=builder /usr/local/cargo/bin/libreddit /usr/local/bin/libreddit
|
2021-04-10 10:50:43 +12:00
|
|
|
|
|
|
|
# Use an unprivileged user.
|
2021-04-10 13:59:04 +12:00
|
|
|
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
|
2021-04-10 10:50:43 +12:00
|
|
|
USER libreddit
|
|
|
|
|
|
|
|
# Tell Docker to expose port 8080
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
# Run a healthcheck every minute to make sure Libreddit 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-10 10:50:43 +12:00
|
|
|
|
2021-04-15 16:50:03 +12:00
|
|
|
CMD ["libreddit"]
|