diff --git a/.github/workflows/docker-arm.yml b/.github/workflows/docker-arm.yml index de23abd..9ab34ad 100644 --- a/.github/workflows/docker-arm.yml +++ b/.github/workflows/docker-arm.yml @@ -30,7 +30,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile + file: ./Dockerfile.arm64 platforms: linux/arm64 push: true tags: spikecodes/libreddit:latest diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index c3afd88..61d9a22 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -1,28 +1,37 @@ #################################################################################################### ## Builder #################################################################################################### -FROM rust:alpine AS builder +FROM rust:latest AS builder -RUN apk add --no-cache g++ +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 install --path . +RUN cargo build --target aarch64-unknown-linux-musl --release #################################################################################################### ## Final image #################################################################################################### -FROM alpine:latest +FROM scratch -RUN apk add --no-cache curl +# 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/local/cargo/bin/libreddit /usr/local/bin/libreddit +COPY --from=builder /usr/src/libreddit/target/aarch64-unknown-linux-musl/release/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