Skip to content
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
7 changes: 7 additions & 0 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Setup buildx
uses: docker/setup-buildx-action@v3

- name: Build and export to Docker local cache
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
with:
# Need load and tags so we can test it below
context: .
load: true
tags: test_tag
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test cli works in cached runtime image
run: docker run --rm test_tag --version
Expand All @@ -47,6 +53,7 @@ jobs:
env:
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: .
push: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ RUN rustup target add x86_64-unknown-linux-musl && \
apt-get install -y musl-tools musl-dev && \
update-ca-certificates

# Build an empty project with only the Cargo files to improve the cache
# performance of the container build. The src directory is expected to change
# most frequently invalidating later caches.
# This downloads and builds the dependencies early allowing built dependencies
# to be cached.
RUN mkdir src && echo 'fn main() {}' > src/main.rs
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN cargo build --release --target x86_64-unknown-linux-musl

COPY ./src ./src

RUN cargo build --release --target x86_64-unknown-linux-musl
Expand Down
Loading