Skip to content

Commit 93cea4e

Browse files
committed
feat(keyfunder): add standalone keyfunder package with Docker workflow
1 parent 5b97d15 commit 93cea4e

22 files changed

Lines changed: 1942 additions & 1 deletion
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build and Push KeyFunder Image to GCR
2+
on:
3+
push:
4+
branches: [main]
5+
tags:
6+
- '**'
7+
pull_request:
8+
paths:
9+
- 'typescript/keyfunder/**'
10+
- '.github/workflows/keyfunder-docker.yml'
11+
workflow_dispatch:
12+
inputs:
13+
include_arm64:
14+
description: 'Include arm64 in the build'
15+
required: false
16+
default: 'false'
17+
18+
concurrency:
19+
group: build-push-keyfunder-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
check-env:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
gcloud-service-key: ${{ steps.gcloud-service-key.outputs.defined }}
27+
steps:
28+
- id: gcloud-service-key
29+
env:
30+
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }}
31+
if: "${{ env.GCLOUD_SERVICE_KEY != '' }}"
32+
run: echo "defined=true" >> $GITHUB_OUTPUT
33+
34+
build-and-push-to-gcr:
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: read
38+
id-token: write
39+
pull-requests: write
40+
41+
needs: [check-env]
42+
if: needs.check-env.outputs.gcloud-service-key == 'true'
43+
44+
steps:
45+
- name: Generate GitHub App Token
46+
id: generate-token
47+
uses: actions/create-github-app-token@v2
48+
with:
49+
app-id: ${{ secrets.HYPER_GONK_APP_ID }}
50+
private-key: ${{ secrets.HYPER_GONK_PRIVATE_KEY }}
51+
52+
- uses: actions/checkout@v5
53+
with:
54+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
55+
submodules: recursive
56+
fetch-depth: 0
57+
58+
- name: Generate tag data
59+
id: taggen
60+
run: |
61+
echo "TAG_DATE=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
62+
echo "TAG_SHA=$(echo '${{ github.event.pull_request.head.sha || github.sha }}' | cut -b 1-7)" >> $GITHUB_OUTPUT
63+
64+
- name: Docker meta
65+
id: meta
66+
uses: docker/metadata-action@v5
67+
with:
68+
images: |
69+
gcr.io/abacus-labs-dev/hyperlane-keyfunder
70+
tags: |
71+
type=ref,event=branch
72+
type=ref,event=pr
73+
type=raw,value=${{ steps.taggen.outputs.TAG_SHA }}-${{ steps.taggen.outputs.TAG_DATE }}
74+
75+
- name: Set up Depot CLI
76+
uses: depot/setup-action@v1
77+
78+
- name: Login to GCR
79+
uses: docker/login-action@v3
80+
with:
81+
registry: gcr.io
82+
username: _json_key
83+
password: ${{ secrets.GCLOUD_SERVICE_KEY }}
84+
85+
- name: Determine platforms
86+
id: determine-platforms
87+
run: |
88+
if [ "${{ github.event.inputs.include_arm64 }}" == "true" ]; then
89+
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
90+
else
91+
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
92+
fi
93+
94+
- name: Get Foundry version
95+
id: foundry-version
96+
run: |
97+
FOUNDRY_VERSION=$(cat solidity/.foundryrc)
98+
echo "FOUNDRY_VERSION=$FOUNDRY_VERSION" >> $GITHUB_OUTPUT
99+
100+
- name: Build and push
101+
id: build
102+
uses: depot/build-push-action@v1
103+
with:
104+
project: 3cpjhx94qv
105+
context: ./
106+
file: ./typescript/keyfunder/Dockerfile
107+
push: true
108+
tags: ${{ steps.meta.outputs.tags }}
109+
labels: ${{ steps.meta.outputs.labels }}
110+
platforms: ${{ steps.determine-platforms.outputs.platforms }}
111+
build-args: |
112+
FOUNDRY_VERSION=${{ steps.foundry-version.outputs.FOUNDRY_VERSION }}
113+
SERVICE_VERSION=${{ steps.taggen.outputs.TAG_SHA }}-${{ steps.taggen.outputs.TAG_DATE }}
114+
115+
- name: Comment image tags on PR
116+
if: github.event_name == 'pull_request'
117+
uses: ./.github/actions/docker-image-comment
118+
with:
119+
comment_tag: keyfunder-docker-image
120+
image_name: KeyFunder Docker Image
121+
emoji: 🔑
122+
image_tags: ${{ steps.meta.outputs.tags }}
123+
pr_number: ${{ github.event.pull_request.number }}
124+
github_token: ${{ steps.generate-token.outputs.token }}
125+
job_status: ${{ job.status }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ yalc.lock
4343
**/deployer-key.json
4444

4545
# .yarn as we use pnpm now
46-
.yarn
46+
.yarn
47+
48+
# opencode
49+
.opencode/

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ COPY typescript/github-proxy/package.json ./typescript/github-proxy/
3131
COPY typescript/helloworld/package.json ./typescript/helloworld/
3232
COPY typescript/http-registry-server/package.json ./typescript/http-registry-server/
3333
COPY typescript/infra/package.json ./typescript/infra/
34+
COPY typescript/keyfunder/package.json ./typescript/keyfunder/
3435
COPY typescript/provider-sdk/package.json ./typescript/provider-sdk/
3536
COPY typescript/radix-sdk/package.json ./typescript/radix-sdk/
3637
COPY typescript/rebalancer/package.json ./typescript/rebalancer/

pnpm-lock.yaml

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/keyfunder/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.env*
2+
/dist
3+
/bundle
4+
/cache
5+
6+
# allow check-in of .env.example
7+
!.env.example

typescript/keyfunder/.mocharc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"import": ["tsx"]
3+
}

typescript/keyfunder/Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM node:20-slim AS builder
2+
3+
WORKDIR /hyperlane-monorepo
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
git g++ make python3 python3-pip jq bash curl ca-certificates unzip \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
ARG FOUNDRY_VERSION
10+
ARG SERVICE_VERSION=dev
11+
ARG TARGETARCH
12+
SHELL ["/bin/bash", "-c"]
13+
RUN set -o pipefail && \
14+
ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64" || echo "amd64") && \
15+
curl --fail -L "https://github.com/foundry-rs/foundry/releases/download/${FOUNDRY_VERSION}/foundry_${FOUNDRY_VERSION}_linux_${ARCH}.tar.gz" | tar -xzC /usr/local/bin forge cast
16+
SHELL ["/bin/sh", "-c"]
17+
18+
COPY package.json ./
19+
RUN corepack enable && corepack install
20+
21+
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
22+
23+
COPY patches ./patches
24+
25+
COPY typescript/keyfunder/package.json ./typescript/keyfunder/
26+
COPY typescript/sdk/package.json ./typescript/sdk/
27+
COPY typescript/provider-sdk/package.json ./typescript/provider-sdk/
28+
COPY typescript/utils/package.json ./typescript/utils/
29+
COPY typescript/cosmos-sdk/package.json ./typescript/cosmos-sdk/
30+
COPY typescript/cosmos-types/package.json ./typescript/cosmos-types/
31+
COPY typescript/radix-sdk/package.json ./typescript/radix-sdk/
32+
COPY typescript/tsconfig/package.json ./typescript/tsconfig/
33+
COPY typescript/eslint-config/package.json ./typescript/eslint-config/
34+
COPY typescript/deploy-sdk/package.json ./typescript/deploy-sdk/
35+
COPY solidity/package.json ./solidity/
36+
COPY solhint-plugin/package.json ./solhint-plugin/
37+
COPY starknet/package.json ./starknet/
38+
39+
RUN pnpm install --frozen-lockfile
40+
41+
COPY turbo.json ./
42+
COPY typescript/keyfunder ./typescript/keyfunder
43+
COPY typescript/sdk ./typescript/sdk
44+
COPY typescript/provider-sdk ./typescript/provider-sdk
45+
COPY typescript/utils ./typescript/utils
46+
COPY typescript/cosmos-sdk ./typescript/cosmos-sdk
47+
COPY typescript/cosmos-types ./typescript/cosmos-types
48+
COPY typescript/radix-sdk ./typescript/radix-sdk
49+
COPY typescript/tsconfig ./typescript/tsconfig
50+
COPY typescript/eslint-config ./typescript/eslint-config
51+
COPY typescript/deploy-sdk ./typescript/deploy-sdk
52+
COPY solidity ./solidity
53+
COPY solhint-plugin ./solhint-plugin
54+
COPY starknet ./starknet
55+
56+
RUN pnpm turbo run bundle --filter=@hyperlane-xyz/keyfunder
57+
58+
FROM node:20-alpine AS runner
59+
60+
WORKDIR /app
61+
62+
RUN apk add --no-cache ca-certificates
63+
64+
COPY --from=builder /hyperlane-monorepo/typescript/keyfunder/bundle ./bundle
65+
66+
RUN npm install @google-cloud/pino-logging-gcp-config
67+
68+
ARG SERVICE_VERSION=dev
69+
ENV NODE_ENV=production
70+
ENV LOG_LEVEL=info
71+
ENV SERVICE_VERSION=${SERVICE_VERSION}
72+
73+
CMD ["node", "bundle/index.js"]

0 commit comments

Comments
 (0)