Skip to content

Commit

Permalink
Merge pull request #118 from bitfinity-network/update-CI
Browse files Browse the repository at this point in the history
Add CI for publishing images to GCP
  • Loading branch information
Yasir authored Feb 5, 2024
2 parents 861756c + d1d136b commit 969871e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
64 changes: 45 additions & 19 deletions .github/workflows/publish-evm-block-extractor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Deploy EVM Block Extractor docker image'
name: 'Deploy EVM Block Extractor Docker Image'

on:
workflow_dispatch: {}
Expand All @@ -8,46 +8,72 @@ on:
tags:
- 'v*'

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.repository_owner}}/evm-block-extractor
IMAGE_NAME: evm-block-extractor
GCP_REGISTRY: us-east4-docker.pkg.dev

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
deploy-to-github:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Log in to the Container registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
id: gh-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image to GitHub Container Registry
uses: docker/build-push-action@v5
with:
context: .
file: ./src/evm-block-extractor/Dockerfile
push: true
tags: ${{ steps.gh-meta.outputs.tags }}

deploy-to-gcp:
runs-on: ubuntu-latest
needs: deploy-to-github
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to GCP Registry
uses: docker/login-action@v3
with:
registry: ${{env.GCP_REGISTRY}}
username: _json_key
password: ${{ secrets.EXTRACTOR_GCP_DOCKER_KEY }}

- name: Extract metadata (tags, labels) for Docker
id: gcp-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{env.GCP_REGISTRY}}/extractor-410310/block-extractor-repo/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
- name: Build and push Docker image to GCP Registry
uses: docker/build-push-action@v5
with:
context: .
file: ./src/evm-block-extractor/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.gcp-meta.outputs.tags }}
18 changes: 8 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
version: "3.3"
version: '3.3'

#
# This docker-compose file is used to start the services for local testing.
# It starts a evm-blockchain-extractor connected to a local postgres database.
#

services:

db:
image: "postgres:11-alpine"
image: 'postgres:11-alpine'
ports:
- "5432:5432"
- '5432:5432'
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres


extractor:
image: ghcr.io/bitfinity-network/evm-block-extractor:main
# image: "evm-block-extractor:latest"
# build:
# dockerfile: ./src/evm-block-extractor/Dockerfile
# image: ghcr.io/bitfinity-network/evm-block-extractor:main
image: "evm-block-extractor:latest"
build:
dockerfile: ./src/evm-block-extractor/Dockerfile
ports:
- "8080:8080"
- '8080:8080'
command: --rpc-url https://testnet.bitfinity.network --postgres --username postgres --password postgres --database-name postgres --database-url db
2 changes: 1 addition & 1 deletion src/evm-block-extractor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::database::DatabaseClient;

const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Simple CLI program for Benchmarking BitFinity Network
/// Simple CLI parser for the EVM block extractor
#[derive(Parser, Debug, Clone)]
#[clap(
version = VERSION,
Expand Down

0 comments on commit 969871e

Please sign in to comment.