Skip to content

Commit

Permalink
Merge pull request #17 from Crossbell-Box/gcp
Browse files Browse the repository at this point in the history
chore(deploy): gcp
  • Loading branch information
incubator4 authored Jan 4, 2024
2 parents 6017462 + 3b6aa4c commit 8a7bfdc
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 104 deletions.
109 changes: 24 additions & 85 deletions .github/workflows/publish-docker-image-every-push.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,31 @@
name: Push and Deploy

name: Build and Deploy
on:
push:
branches:
- master
env:
OTP_VERSION: '24.3.4.1'
ELIXIR_VERSION: '1.13.4'
IMAGE_NAME: rss3/blockscout
REGION_ID: us-east-1
DEV_ACK_CLUSTER_ID: cd1d0ffc40b5242b39ddda1864e71e30d
PROD_ACK_CLUSTER_ID: cfc647c22fd6848b5a602ad4d7470632b

tags:
- v*
jobs:
build:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
push: true
cache-from: type=registry,ref=rss3/blockscout:buildcache
cache-to: type=registry,ref=rss3/blockscout:buildcache,mode=max
tags: ${{ steps.meta.outputs.tags }}
# build-args: |
# CACHE_EXCHANGE_RATES_PERIOD=
# DISABLE_READ_API=false
# API_PATH=
# NETWORK_PATH=
# DISABLE_WEBAPP=false
# DISABLE_WRITE_API=false
# CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER=
# WOBSERVER_ENABLED=false
# ADMIN_PANEL_ENABLED=false
# CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL=
# DISABLE_BRIDGE_MARKET_CAP_UPDATER=false
# CACHE_BRIDGE_MARKET_CAP_UPDATE_INTERVAL=
# SOCKET_ROOT=

uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main
with:
images: flosspicks/blockscout
context: ./docker/Dockerfile
dockerfile: ./Dockerfile
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
deploy-prod:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set K8s context
uses: aliyun/ack-set-context@v1
with:
access-key-id: "${{ secrets.ACCESS_KEY_ID }}"
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}"
cluster-id: "${{ env.PROD_ACK_CLUSTER_ID }}"
- name: Install Tools
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && mv yq_linux_amd64 /usr/local/bin/yq
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.22.10/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/kubectl
- uses: sljeff/secrets2env@main
with:
secrets-json: ${{ toJson(secrets) }}
- name: Deploy
env:
IMAGE_TAG_RELEASE: ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }}
run: |
sh apply.sh deploy/prod/*
uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main
needs:
- build
with:
images: flosspicks/blockscout
tag: sha-${{ github.sha }}
cluster: prod
namespace: crossbell
releaseName: blockscout
revision: master
dir: deploy/prod
secrets:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
15 changes: 4 additions & 11 deletions deploy/prod/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ spec:
app: blockscout
tier: api
spec:
nodeSelector:
rss3.io/usage: csb-others
tolerations:
- key: "rss3.io/usage"
operator: "Equal"
value: "csb-others"
effect: "NoSchedule"
initContainers:
- image: ${IMAGE_TAG_RELEASE}
- image: flosspicks/blockscout
imagePullPolicy: Always
name: blockscout-init
command:
Expand All @@ -39,17 +32,17 @@ spec:
- '"Elixir.Explorer.ReleaseTasks.create_and_migrate()"'
envFrom:
- secretRef:
name: blockscout-secret
name: blockscout
containers:
- image: ${IMAGE_TAG_RELEASE}
- image: flosspicks/blockscout
imagePullPolicy: Always
name: blockscout
command:
- bin/blockscout
- start
envFrom:
- secretRef:
name: blockscout-secret
name: blockscout
ports:
- containerPort: 4000
protocol: TCP
Expand Down
8 changes: 8 additions & 0 deletions deploy/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deploy.yaml
- route.yaml
- secret.yaml
- svc.yaml
12 changes: 6 additions & 6 deletions deploy/prod/route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
namespace: crossbell
spec:
entryPoints:
- web
- websecure
routes:
- kind: Rule
match: Host(`scan.crossbell.io`) && PathPrefix(`/`)
services:
- name: blockscout-api
port: 4000
- kind: Rule
match: Host(`scan.crossbell.io`)
services:
- name: blockscout
port: 4000
2 changes: 1 addition & 1 deletion deploy/prod/secrets.yaml → deploy/prod/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: blockscout-secret
name: blockscout
namespace: crossbell
stringData:
SECRET_KEY_BASE: $SECRET_KEY_BASE
Expand Down
2 changes: 1 addition & 1 deletion deploy/prod/svc.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: blockscout-api
name: blockscout
namespace: crossbell
spec:
type: ClusterIP
Expand Down

0 comments on commit 8a7bfdc

Please sign in to comment.