Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARD-913 Added ENV for config and Docker image building workflow #74 #77

Merged
merged 8 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Create and publish a Docker image

on:
push:
branches: ['dev']
workflow_dispatch:
inputs:
tag:
description: 'Tag for the Docker image'
required: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
display-image-name:
runs-on: ubuntu-latest
steps:
- name: Display IMAGE_NAME
run: echo "IMAGE_NAME is ${{ env.IMAGE_NAME }}"
arhamj marked this conversation as resolved.
Show resolved Hide resolved
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short commit hash and determine branch name
id: set-env-vars
run: |
# Get short commit hash
echo "SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# Determine branch name
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV # Source branch of the PR
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV # Actual branch name for push events
fi
- name: Set Docker image tag
id: set-docker-tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "DOCKER_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ env.BRANCH_NAME }}-${{ env.SHORT_COMMIT_HASH }}" >> $GITHUB_ENV
fi
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}
labels: |
version=${{ env.SHORT_COMMIT_HASH }}
branch=${{ env.BRANCH_NAME }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# syntax=docker/dockerfile:1

## global args
ARG NODE_VERSION=18.16.1
ARG NODE_ENV=production

FROM node:${NODE_VERSION}
SHELL [ "/bin/bash", "-cex" ]
FROM node:18.16.1-alpine
SHELL [ "/bin/sh", "-cex" ]

## ENVs
ENV NODE_ENV=${NODE_ENV}
Expand Down
11 changes: 6 additions & 5 deletions local_fast_refresh.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
diff --git a/src/config.ts b/src/config.ts
--- a/src/config.ts (revision e0fd622f7257642c37243f3da9303dfaa55c1872)
+++ b/src/config.ts (date 1713205409743)
@@ -131,8 +131,8 @@
index a633cf3..8c3df19 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -135,8 +135,8 @@ export const CONFIG: Config = {
explorerUrl: process.env.EXPLORER_URL || 'http://127.0.0.1:6001',
queryFromExplorer: false,
generateTxTimestamp: true,
- nodelistRefreshInterval: 30000,
- nodelistRefreshInterval: Number(process.env.NODELIST_REFRESH_INTERVAL) || 30000,
- defaultRequestRetry: 5,
+ nodelistRefreshInterval: 5000,
+ defaultRequestRetry: 10,
gasEstimateMethod: 'serviceValidator', //serviceValidator or replayEngine or validator
gasEstimateMethod: process.env.GAS_ESTIMATE_METHOD || 'serviceValidator', //serviceValidator or replayEngine or validator
gasEstimateInvalidationIntervalInMs: 1000 * 60 * 60 * 2, // 2 hours
gasEstimateUseCache: false,
10 changes: 5 additions & 5 deletions local_tests.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/src/config.ts b/src/config.ts
index db6061c4..712ab94f 100644
index a633cf3..1c398bb 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -134,10 +134,10 @@ export const CONFIG: Config = {
@@ -137,10 +137,10 @@ export const CONFIG: Config = {
generateTxTimestamp: true,
nodelistRefreshInterval: 30000,
nodelistRefreshInterval: Number(process.env.NODELIST_REFRESH_INTERVAL) || 30000,
defaultRequestRetry: 5,
- gasEstimateMethod: 'serviceValidator', //serviceValidator or replayEngine or validator
- gasEstimateMethod: process.env.GAS_ESTIMATE_METHOD || 'serviceValidator', //serviceValidator or replayEngine or validator
+ gasEstimateMethod: 'replayEngine', //serviceValidator or replayEngine or validator
gasEstimateInvalidationIntervalInMs: 1000 * 60 * 60 * 2, // 2 hours
gasEstimateUseCache: false,
- staticGasEstimate: '0x5B8D80', // comment out rather than delete this line
- staticGasEstimate: process.env.STATIC_GAS_ESTIMATE || '0x5B8D80', // comment out rather than delete this line
+ staticGasEstimate: '0x2DC6C0', // comment out rather than delete this line
defaultRequestTimeout: {
default: 2000,
Expand Down
12 changes: 6 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const CONFIG: Config = {
port: Number(process.env.LOG_SERVER_PORT) || 4446,
},
ip: '0.0.0.0',
port: 8080,
port: Number(process.env.RPC_PORT) || 8080,
chainId: 8082,
nodeIpInfo: {
externalIp: process.env.NODE_EXTERNAL_IP || '127.0.0.1',
Expand All @@ -131,23 +131,23 @@ export const CONFIG: Config = {
askLocalHostForArchiver: true,
rotationInterval: 60,
faucetServerUrl: process.env.FAUCET_URL || 'https://faucet.liberty10.shardeum.org',
queryFromValidator: true,
queryFromValidator: Boolean(process.env.QUERY_FROM_VALIDATOR) || true,
explorerUrl: process.env.EXPLORER_URL || 'http://127.0.0.1:6001',
queryFromExplorer: false,
generateTxTimestamp: true,
nodelistRefreshInterval: 30000,
nodelistRefreshInterval: Number(process.env.NODELIST_REFRESH_INTERVAL) || 30000,
defaultRequestRetry: 5,
gasEstimateMethod: 'serviceValidator', //serviceValidator or replayEngine or validator
gasEstimateMethod: process.env.GAS_ESTIMATE_METHOD || 'serviceValidator', //serviceValidator or replayEngine or validator
gasEstimateInvalidationIntervalInMs: 1000 * 60 * 60 * 2, // 2 hours
gasEstimateUseCache: false,
staticGasEstimate: '0x5B8D80', // comment out rather than delete this line
staticGasEstimate: process.env.STATIC_GAS_ESTIMATE || '0x5B8D80', // comment out rather than delete this line
defaultRequestTimeout: {
default: 2000,
contract: 7000,
account: 10000,
full_nodelist: 10000,
},
aalgWarmup: false,
aalgWarmup: Boolean(process.env.AALG_WARMUP) || true,
aalgWarmupServiceTPS: 10,
recordTxStatus: false, // not safe for production, keep this off. Known issue.
rateLimit: false,
Expand Down
Loading