Skip to content

Commit

Permalink
feat(docker): improve Dockerfile by caching cargo dependencies (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
chikof authored Nov 20, 2024
2 parents 97a62fb + 09dbe7d commit fa4323b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -9,8 +9,17 @@ ARG DIESEL_CLI_VERSION=2.2.4

RUN apt-get update \
&& apt-get install -y postgresql \
&& rm -rf /var/lib/apt/lists/* \
&& cargo install diesel_cli --version $DIESEL_CLI_VERSION --no-default-features --features postgres
&& rm -rf /var/lib/apt/lists/*

# Install diesel-cli
RUN cargo install diesel_cli --version $DIESEL_CLI_VERSION --no-default-features --features postgres

# Cache cargo dependencies
COPY Cargo.toml Cargo.lock ./
COPY build.rs ./
RUN mkdir src && echo "fn main() {}" > src/main.rs \
&& cargo build --release \
&& rm -rf src

COPY . .

0 comments on commit fa4323b

Please sign in to comment.