Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cargo-chef #110

Merged
merged 3 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
context: .
tags: achristmascarl/rainfrog:latest,achristmascarl/rainfrog:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max`
cache-to: type=gha,mode=max

publish-cargo:
name: Publishing to Cargo
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: build docker image
run: |
docker build . -t rainfrog_test
- name: Set up Docker CLI
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: false
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: rainfrog_test
outputs: type=docker
- name: init db for docker test
run: |
make db-up
Expand Down
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
FROM rust:alpine3.20 AS builder
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app

# Install system dependencies
RUN apk add --no-cache musl-dev=1.2.5-r0
# Cache dependencies
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

# Build application
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release
Expand Down