Skip to content

feat: Dockerfile

feat: Dockerfile #8

Workflow file for this run

name: Mindpress Production Docker Image CI ### rename Github Action ###
on:
pull_request:
branches: [main]
push:
branches: [ui]
env:
CI: false
REGION: us-east-1
ECR_REGISTRY_ID: 553885929720
STATIC_BUCKET: tf-nodereal-prod-nodereal-static
### IMPORTANT !!!! ###
### The following three need to be modified according to your project ###
APP_NAME: mindpress ### your application name
GIT_SYNC_PATH_TESTNET: prod/gitops/tf-nodereal-prod-noderealap/web-ui/mindpress/values.yaml
GIT_SYNC_PATH_MAINNET: prod/gitops/tf-nodereal-prod-noderealus/web-ui/mindpress/values.yaml ### fit your service config path in https://github.com/node-real/nodereal-app
TAG_FIELD: .nodereal-app.image.tag ### fit your service config path in https://github.com/node-real/nodereal-app: https://app.clickup.com/25652588/v/dc/revbc-8947/revbc-20047?comment=854233399
jobs:
build:
runs-on: ubuntu-latest
# if: "contains(github.event.head_commit.message, 'aptos-trace')"
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- uses: ./.github/actions/ci-setup
- name: Build React App
run: |
PUBLIC_URL=https://static.nodereal.cc/static/gf-marketplace
GENERATE_SOURCEMAP=false
# Testnet
REACT_APP_GF_EXPLORER_URL=https://greenfieldscan.com/
REACT_APP_BSC_EXPLORER_URL=https://testnet.bscscan.com/
REACT_APP_DCELLAR_URL=https://testnet.dcellar.io/
REACT_APP_GF_CHAIN_ID=5600
REACT_APP_GF_RPC_URL=https://gnfd-testnet-fullnode-tendermint-us.bnbchain.org
REACT_APP_BSC_RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545
REACT_APP_BSC_CHAIN_ID=97
REACT_APP_MARKETPLACE_CONTRACT_ADDRESS =0xaa80E8Ee052BaA700c3Ca5b35ce5F02EeF02368d
REACT_APP_GROUP_HUB_CONTRACT_ADDRESS =0x50B3BF0d95a8dbA57B58C82dFDB5ff6747Cc1a9E
REACT_APP_MULTI_CALL_CONTRACT_ADDRESS =0x50f6210b85d38F5d0E660D6C8978C9bdCd12F130
REACT_APP_ERC1155_TRANSFER_CONTRACT_ADDRESS =0x43bdF3d63e6318A2831FE1116cBA69afd0F05267
REACT_APP_ERC721_TRANSFER_CONTRACT_ADDRESS =0x7fC61D6FCA8D6Ea811637bA58eaf6aB17d50c4d1
REACT_APP_NETWORK=Testnet
REACT_APP_DAPP_NAME=mindt1020
G_TAG=G-SHLTDD3YG4
REACT_APP_API_DOMAIN=https://gnfd-testnet-marketplace.bnbchain.org/v1/
pnpm run build
- name: Build, tag, and push image to Amazon ECR
id: image
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws-assume-role.outputs.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws-assume-role.outputs.aws_secret_key }}
AWS_SESSION_TOKEN: ${{ steps.aws-assume-role.outputs.aws_sessions_token }}
run: |
GIT_COMMIT=${GITHUB_SHA}
IMAGE_NAME="${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com/${APP_NAME}:${GITHUB_SHA}"
aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin ${ECR_REGISTRY_ID}.dkr.ecr.${REGION}.amazonaws.com
#### Write your own build arg for your project
docker build --build-arg COMMIT_SHA=${GIT_COMMIT} \
-f Dockerfile . -t ${IMAGE_NAME}
docker push ${IMAGE_NAME}
echo ::set-output name=image_id::$IMAGE_NAME
- uses: shrink/actions-docker-extract@v1
id: extract
with:
image: ${{ steps.image.outputs.image_id }}
path: /opt/deploy/assets
- name: upload static file to qa s3 bucket from CI artifact
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws-assume-role.outputs.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws-assume-role.outputs.aws_secret_key }}
AWS_SESSION_TOKEN: ${{ steps.aws-assume-role.outputs.aws_sessions_token }}
run: |
aws s3 cp ${{ steps.extract.outputs.destination }}/assets/.next/static s3://${STATIC_BUCKET}/static/aptos-trace/_next/static --recursive --cache-control "private, max-age=259200"
aws s3 cp ${{ steps.extract.outputs.destination }}/assets/public s3://${STATIC_BUCKET}/static/aptos-trace --recursive --cache-control "private, max-age=259200"
- name: clone the gitops config repo
uses: actions/checkout@v3
with:
repository: node-real/nodereal-app
token: ${{ secrets.GO_MODULES_TOKEN }}
- name: update image tag in gitops config repo for testnet
env:
GIT_SYNC_PATH: ${{ env.GIT_SYNC_PATH_TESTNET }}
TAG_FIELD: ${{ env.TAG_FIELD }}
run: |
yq e "$TAG_FIELD = \"${GITHUB_SHA}\"" -i $GIT_SYNC_PATH
- name: update image tag in gitops config repo for mainnet
env:
GIT_SYNC_PATH: ${{ env.GIT_SYNC_PATH_MAINNET }}
TAG_FIELD: ${{ env.TAG_FIELD }}
run: |
yq e "$TAG_FIELD = \"${GITHUB_SHA}\"" -i $GIT_SYNC_PATH
- name: Set PR branch name
id: vars
run: echo ::set-output name=branch-name::"github-action-patches/${GITHUB_SHA::7}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GO_MODULES_TOKEN }}
commit-message: update image tag
title: github action APTOS-TRACE deploy auto-update
body: lgtm
branch: ${{ steps.vars.outputs.branch-name }}
labels: |
lgtm
approved