Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit fa4323b

Browse files
authored
feat(docker): improve Dockerfile by caching cargo dependencies (#118)
2 parents 97a62fb + 09dbe7d commit fa4323b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ ARG DIESEL_CLI_VERSION=2.2.4
99

1010
RUN apt-get update \
1111
&& apt-get install -y postgresql \
12-
&& rm -rf /var/lib/apt/lists/* \
13-
&& cargo install diesel_cli --version $DIESEL_CLI_VERSION --no-default-features --features postgres
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install diesel-cli
15+
RUN cargo install diesel_cli --version $DIESEL_CLI_VERSION --no-default-features --features postgres
16+
17+
# Cache cargo dependencies
18+
COPY Cargo.toml Cargo.lock ./
19+
COPY build.rs ./
20+
RUN mkdir src && echo "fn main() {}" > src/main.rs \
21+
&& cargo build --release \
22+
&& rm -rf src
1423

1524
COPY . .
1625

0 commit comments

Comments
 (0)