Skip to content

Commit

Permalink
feat(docker): improve Dockerfile by caching cargo dependencies
Browse files Browse the repository at this point in the history
Enhance the Dockerfile by adding a step to cache cargo dependencies, 
which reduces build time. Separate the installation of diesel_cli 
to streamline the process. The changes ensure a more efficient 
build process by including only necessary steps and managing 
dependencies effectively.
  • Loading branch information
chikof committed Nov 20, 2024
1 parent 97a62fb commit 09dbe7d
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
Expand Up @@ -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 . .

Expand Down

0 comments on commit 09dbe7d

Please sign in to comment.