Skip to content

Commit

Permalink
chore: README and CI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Dec 13, 2023
1 parent 29b59bb commit b3aeaaa
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 605 deletions.
159 changes: 0 additions & 159 deletions .github/workflows/build-and-deploy.yml

This file was deleted.

99 changes: 0 additions & 99 deletions .github/workflows/docker-image-build-push.yml

This file was deleted.

137 changes: 137 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: "Build multi-arch images"

on:
push:
tags:
- "v*.*.*"

jobs:
image-info:
name: "Extract crate info"
runs-on: "ubuntu-latest"
outputs:
version: ${{ steps.derive.outputs.version }}

steps:
- id: "derive"
name: "Derive image info from Git tag"
run: |
FULL_REF="${{ github.ref }}"
REGEX="^refs\/tags\/v(.*)$"
[[ $FULL_REF =~ $REGEX ]];
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
build-amd64:
name: "Build for linux/amd64"
runs-on: "ubuntu-latest"
needs:
- "image-info"

env:
DOCKER_REPOSITORY: "starknet/juno-firehose"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Build Docker image"
run: |
docker buildx build \
--platform "linux/amd64" \
-t ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-amd64 -f ./Dockerfile .
- name: "Export Docker image"
run: |
docker save ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-amd64 | gzip > /tmp/amd64.tar.gz
- name: "Upload Docker image artifact"
uses: "actions/upload-artifact@v3"
with:
name: "amd64.tar.gz"
path: "/tmp/amd64.tar.gz"

build-arm64:
name: "Build for linux/arm64"
runs-on: "ubuntu-latest"
needs:
- "image-info"

env:
DOCKER_REPOSITORY: "starknet/juno-firehose"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Set up Docker Buildx"
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
sudo systemctl restart docker
docker buildx create --name multi_builder
docker buildx use multi_builder
- name: "Build Docker image"
run: |
docker buildx build \
--platform "linux/arm64/v8" \
--output=type=docker \
-t ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-arm64 -f ./Dockerfile .
- name: "Export Docker image"
run: |
docker save ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-arm64 | gzip > /tmp/arm64.tar.gz
- name: "Upload Docker image artifact"
uses: "actions/upload-artifact@v3"
with:
name: "arm64.tar.gz"
path: "/tmp/arm64.tar.gz"

push:
name: "Push multi-arch manifest"
runs-on: "ubuntu-latest"
needs:
- "build-amd64"
- "build-arm64"
- "image-info"

env:
DOCKER_REPOSITORY: "starknet/juno-firehose"

steps:
- name: "Download linux/amd64 image"
uses: "actions/download-artifact@v3"
with:
name: "amd64.tar.gz"
path: "/tmp/"

- name: "Download linux/arm64/v8 image"
uses: "actions/download-artifact@v3"
with:
name: "arm64.tar.gz"
path: "/tmp/"

- name: "Load Docker images"
run: |
docker load < /tmp/amd64.tar.gz
docker load < /tmp/arm64.tar.gz
- name: "Login to Docker Hub"
uses: "docker/[email protected]"
with:
username: "${{ secrets.DOCKER_HUB_USERNAME }}"
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"

- name: "Push Docker image"
run: |
docker push ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-amd64
docker push ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-arm64
docker manifest create ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }} \
${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-amd64 \
${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-arm64
docker manifest create ${DOCKER_REPOSITORY}:latest \
${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-amd64 \
${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}-arm64
docker manifest push ${DOCKER_REPOSITORY}:${{ needs.image-info.outputs.version }}
docker manifest push ${DOCKER_REPOSITORY}:latest
Loading

0 comments on commit b3aeaaa

Please sign in to comment.