Skip to content

Commit

Permalink
ci(migration): improve dockerfile caching and utilize caching
Browse files Browse the repository at this point in the history
  • Loading branch information
dsonck92 committed Jul 26, 2024
1 parent eaf1544 commit 9f6991d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: ./migrations
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64
13 changes: 10 additions & 3 deletions migrations/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ FROM rust:1.79-alpine AS rust-builder

WORKDIR /build

RUN cargo install cargo-build-dependencies
RUN apk add --no-cache musl-dev
COPY Cargo.toml Cargo.lock ./

RUN ARCH=$(apk --print-arch); \
cargo build-dependencies --release --target=${ARCH}-unknown-linux-musl;

COPY . ./

RUN apk add --no-cache musl-dev
RUN rustc --print target-list
RUN export ARCH=$(apk --print-arch); \
RUN ARCH=$(apk --print-arch); \
cargo build --release --locked --target=${ARCH}-unknown-linux-musl; \
mv /build/target/${ARCH}-unknown-linux-musl/release/migrate /build/migrate

Expand All @@ -26,4 +31,6 @@ COPY --from=rust-builder /build/migrate /migrate

ENTRYPOINT ["/migrate"]

CMD ["up"]

EXPOSE 3000

0 comments on commit 9f6991d

Please sign in to comment.