Skip to content

Commit 1171d89

Browse files
committed
Optimize Dockerfile
1 parent 42678ba commit 1171d89

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

echo/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ RUN mkdir bin && \
88
apt update -y && apt upgrade -y && apt install -y musl-tools && \
99
rustup target add x86_64-unknown-linux-musl
1010

11-
# Mounting src using bind mount is slower for some reason
12-
COPY src src
13-
1411
# NOTE: Due to caching this is actually faster than using
1512
# Two separate cargo builds (one without source present).
1613
RUN --mount=type=cache,target=target \
1714
--mount=type=cache,target=/usr/local/cargo/git \
1815
--mount=type=cache,target=/usr/local/cargo/registry \
16+
--mount=type=bind,source=src,target=src \
17+
--mount=type=bind,source=openapi.json,target=openapi.json \
1918
--mount=type=bind,source=Cargo.toml,target=Cargo.toml,readwrite \
2019
--mount=type=bind,source=Cargo.lock,target=Cargo.lock,readwrite \
21-
--mount=type=bind,source=openapi.json,target=openapi.json,readwrite \
2220
# Use musl target as the binary is about 1MiB smaller
2321
cargo build --profile $PROFILE --target x86_64-unknown-linux-musl && \
2422
# The "dev" target directory is named "debug" instead

0 commit comments

Comments
 (0)