Skip to content

Commit 1ce429d

Browse files
committed
Try to separate build from final image
1 parent 2d42aa1 commit 1ce429d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Dockerfile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# syntax=docker/dockerfile:1
2-
FROM rust:latest AS build
3-
RUN apt update
4-
RUN apt install -y s3cmd tar zstd awscli clang build-essential
5-
RUN adduser --disabled-password --gecos "mutants" mutants
2+
FROM rust:latest AS base
3+
RUN apt update && apt dist-upgrade -y && apt install -y s3cmd tar zstd awscli clang build-essential
4+
RUN adduser --uid 1000 --disabled-password --gecos "mutants" mutants
65

7-
USER mutants
6+
FROM base AS build
87
WORKDIR /home/mutants
8+
USER mutants
9+
COPY --chown=mutants:mutants . mutants-src
10+
RUN --mount=type=cache,target=mutants-src/target,uid=1000 \
11+
--mount=type=cache,target=/home/mutants/.cargo,uid=1000 \
12+
cargo install -v --locked --path=mutants-src --root=buildroot
13+
RUN pwd && ls -la . buildroot
14+
RUN --mount=type=cache,target=/home/mutants/.cargo,uid=1000 \
15+
cargo install --locked cargo-nextest --root=buildroot
916

10-
RUN cargo install --locked cargo-nextest
11-
RUN --mount=type=bind,source=.,target=/src,rw cargo install --locked --path=/src
12-
13-
# TODO: Copy everything to a final image that doesn't need the build artifacts?
14-
15-
# FROM rust:latest AS final
16-
# COPY --from=build /build/release/cargo-mutants /usr/local/bin/
17+
FROM base AS final
18+
USER mutants
19+
COPY --from=build /home/mutants/buildroot/bin/* /usr/local/bin/

0 commit comments

Comments
 (0)