diff --git a/.github/workflows/build-migrations.yml b/.github/workflows/build-migrations.yml index d8304382c..09adb9889 100644 --- a/.github/workflows/build-migrations.yml +++ b/.github/workflows/build-migrations.yml @@ -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 diff --git a/migrations/Dockerfile b/migrations/Dockerfile index c29aec05b..a4b74f1af 100644 --- a/migrations/Dockerfile +++ b/migrations/Dockerfile @@ -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 @@ -26,4 +31,6 @@ COPY --from=rust-builder /build/migrate /migrate ENTRYPOINT ["/migrate"] +CMD ["up"] + EXPOSE 3000