libreddit/Dockerfile.arm

46 lines
1.7 KiB
Docker
Raw Normal View History

2021-04-09 22:50:43 +00:00
####################################################################################################
## Builder
####################################################################################################
2021-04-18 04:32:48 +00:00
FROM rust:alpine AS builder
2022-11-22 22:42:10 +00:00
RUN apk add --no-cache g++ git
2021-04-09 22:50:43 +00:00
WORKDIR /usr/src/libreddit
2023-03-13 06:36:25 +00:00
# cache dependencies in their own layer
COPY Cargo.lock Cargo.toml .
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo install --config net.git-fetch-with-cli=true --path . && rm -rf ./src
2021-04-09 22:50:43 +00:00
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
2022-11-22 22:42:10 +00:00
# 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 .
2021-04-09 22:50:43 +00:00
####################################################################################################
## Final image
####################################################################################################
2021-04-18 04:32:48 +00:00
FROM alpine:latest
2021-04-09 22:50:43 +00:00
2021-04-15 04:50:03 +00: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-09 22:50:43 +00:00
# Copy our build
2021-04-10 01:59:04 +00:00
COPY --from=builder /usr/local/cargo/bin/libreddit /usr/local/bin/libreddit
2021-04-09 22:50:43 +00:00
# Use an unprivileged user.
2021-04-10 01:59:04 +00:00
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
2021-04-09 22:50:43 +00: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 05:38:13 +00:00
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
2021-04-09 22:50:43 +00:00
2021-04-15 04:50:03 +00:00
CMD ["libreddit"]