Use alpine only for ARM builds
This commit is contained in:
parent
2974d92e30
commit
6ce82c36fb
@ -1,37 +1,28 @@
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
## Builder
|
## Builder
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
FROM rust:latest AS builder
|
FROM rust:alpine AS builder
|
||||||
|
|
||||||
RUN rustup target add aarch64-unknown-linux-musl
|
RUN apk add --no-cache g++
|
||||||
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
|
WORKDIR /usr/src/libreddit
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN cargo build --target aarch64-unknown-linux-musl --release
|
RUN cargo install --path .
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
## Final image
|
## Final image
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
FROM scratch
|
FROM alpine:latest
|
||||||
|
|
||||||
# Import user information from builder.
|
RUN apk add --no-cache curl
|
||||||
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 our build
|
||||||
COPY --from=builder /usr/src/libreddit/target/aarch64-unknown-linux-musl/release/libreddit /usr/local/bin/libreddit
|
COPY --from=builder /usr/local/cargo/bin/libreddit /usr/local/bin/libreddit
|
||||||
|
|
||||||
# Use an unprivileged user.
|
# Use an unprivileged user.
|
||||||
|
RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit
|
||||||
USER libreddit
|
USER libreddit
|
||||||
|
|
||||||
# Tell Docker to expose port 8080
|
# Tell Docker to expose port 8080
|
||||||
|
Loading…
Reference in New Issue
Block a user