From 758102fef88d2267c3c83b6849534555821b951f Mon Sep 17 00:00:00 2001 From: Luis Eduardo Boiko Ferreira Date: Thu, 5 Dec 2024 11:57:08 -0300 Subject: [PATCH] Adding github action to publish docker images to github registry (#11) * Adding github action to publish docker images to github registry * Updating workflow --- .github/workflows/release.yml | 90 +++++++++++++++++++++++++++ substreams-sink/Dockerfile.production | 2 +- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ae7beaf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,90 @@ +name: Release and Publish + +on: + push: + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + OWNER: ${{ github.repository_owner }} + RUST_VERSION: 1.75.0 + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Build and push Consumer image + uses: docker/build-push-action@v5 + with: + context: . + file: consumer/Dockerfile.production + push: true + tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/consumer:${{ steps.meta.outputs.version }},${{ env.REGISTRY }}/${{ env.OWNER }}/consumer:latest + build-args: | + RUST_VERSION=${{ env.RUST_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push Image Guard + uses: docker/build-push-action@v5 + with: + context: . + file: image-guard/Dockerfile.production + push: true + tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/image-guard:${{ steps.meta.outputs.version }},${{ env.REGISTRY }}/${{ env.OWNER }}/image-guard:latest + build-args: | + RUST_VERSION=${{ env.RUST_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push Substreams Sink + uses: docker/build-push-action@v5 + with: + context: . + file: substreams-sink/Dockerfile.production + push: true + tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/substreams-sink:${{ steps.meta.outputs.version }},${{ env.REGISTRY }}/${{ env.OWNER }}/substreams-sink:latest + build-args: | + RUST_VERSION=${{ env.RUST_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push Hasura + uses: docker/build-push-action@v5 + with: + context: hasura + file: hasura/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/hasura:${{ steps.meta.outputs.version }},${{ env.REGISTRY }}/${{ env.OWNER }}/hasura:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + name: Release ${{ steps.meta.outputs.version }} + draft: false + prerelease: false + generate_release_notes: true \ No newline at end of file diff --git a/substreams-sink/Dockerfile.production b/substreams-sink/Dockerfile.production index a110dcf..69ff4ca 100644 --- a/substreams-sink/Dockerfile.production +++ b/substreams-sink/Dockerfile.production @@ -24,7 +24,7 @@ RUN cargo chef cook --release --recipe-path recipe.json COPY . . ENV SQLX_OFFLINE=true -RUN cargo build --release --bin substreams-sink --features local +RUN cargo build --release --bin substreams-sink # Stage 3 - Final runtime image FROM debian:bookworm-slim AS runtime