Create dockerfile for arm64

This commit is contained in:
spikecodes 2021-04-09 15:50:43 -07:00
parent c8965ae51b
commit 49bfe4d27c
No known key found for this signature in database
GPG key ID: 004CECFF9B463BCB

43
Dockerfile.arm64 Normal file
View file

@ -0,0 +1,43 @@
####################################################################################################
## Builder
####################################################################################################
FROM rust:latest AS builder
RUN rustup target add aarch64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
WORKDIR /usr/src/libreddit
COPY . .
RUN cargo build --target aarch64-unknown-linux-musl --release
####################################################################################################
## Final image
####################################################################################################
FROM scratch
# Import user information from builder.
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
# 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/src/libreddit/target/aarch64-unknown-linux-musl/release/libreddit /usr/local/bin/libreddit
# Use an unprivileged user.
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 curl -f http://localhost:8080/settings || exit 1
CMD ["libreddit"]