Skip to content

Commit b321e85

Browse files
authored
[KLC-1668] Fix create_release workflow (#19)
* add bridge relayer dockerfile * update create_release workflow * update go mod vendor cache-name
1 parent 3e99228 commit b321e85

File tree

3 files changed

+58
-96
lines changed

3 files changed

+58
-96
lines changed

.github/actions/go-setup-action/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ runs:
4040
if: inputs.cache-enabled == 'true'
4141
uses: actions/cache@v4
4242
env:
43-
cache-name: go-cache-vendor
43+
cache-name: cache-vendor
4444
with:
4545
path: |
4646
~/go/pkg/mod
47-
./vendor
47+
vendor
4848
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
4949
restore-keys: |
5050
${{ runner.os }}-${{ env.cache-name }}-
Lines changed: 8 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,13 @@
11
name: Create release
22

3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
permissions:
9-
contents: write
10-
pull-requests: write
3+
on: workflow_dispatch
114

125
jobs:
136
build:
14-
strategy:
15-
matrix:
16-
runs-on: [ubuntu-latest, macos-latest]
17-
runs-on: ${{ matrix.runs-on }}
18-
name: Build
19-
steps:
20-
- name: Set up Go 1.x
21-
uses: actions/setup-go@v3
22-
with:
23-
go-version: 1.20.7
24-
id: go
25-
26-
- name: Check out code into the Go module directory
27-
uses: actions/checkout@v3
28-
with:
29-
fetch-depth: "0"
30-
31-
- name: Get dependencies
32-
run: |
33-
go get -v -t -d ./...
34-
if [ -f Gopkg.toml ]; then
35-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
36-
dep ensure
37-
fi
38-
39-
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
40-
- name: Set environment variables
41-
run: |
42-
APP_VER_SHORT=$(git describe --tags)
43-
GOOS=$(go env GOOS)
44-
GOARCH=$(go env GOARCH)
45-
GOPATH=$(go env GOPATH)
46-
ARCHIVE="kc_eth_bridge""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"
47-
BUILD_DIR=${GITHUB_WORKSPACE}/build
48-
49-
echo "GOOS=${GOOS}" >> $GITHUB_ENV
50-
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
51-
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
52-
echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
53-
54-
- name: Build
55-
run: |
56-
mkdir -p ${BUILD_DIR}
57-
cd ${GITHUB_WORKSPACE}/cmd/bridge && go build -o "${BUILD_DIR}/" -a -i -ldflags="-X main.appVersion=${APP_VER}"
58-
59-
- name: Package
60-
run: |
61-
cd ${GITHUB_WORKSPACE}
62-
63-
cd ${BUILD_DIR}
64-
tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" *
65-
stat ${GITHUB_WORKSPACE}/${ARCHIVE}
66-
67-
- name: Save artifacts
68-
uses: actions/upload-artifact@v3
69-
with:
70-
name: ${{ env.ARCHIVE }}
71-
path: ${{ github.workspace }}/${{ env.ARCHIVE }}
72-
if-no-files-found: error
73-
74-
release:
75-
needs: [build]
76-
runs-on: ubuntu-latest
77-
steps:
78-
- name: Check out code
79-
uses: actions/checkout@v3
80-
81-
# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
82-
# A directory for each artifact is created using its name
83-
- name: Download all workflow run artifacts
84-
uses: actions/download-artifact@v3
85-
with:
86-
path: assets
87-
88-
- name: Display structure of downloaded files
89-
run: ls -R
90-
working-directory: assets
91-
92-
- name: Create release
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
run: |
96-
hub release create --draft --message="Release draft from Github Actions" vNext
97-
for i in $(find ./assets -name '*.tgz' -type f); do
98-
hub release edit --attach=${i} --message="" vNext
99-
done
7+
uses: klever-io/workflow-calls/.github/workflows/docker.yaml@master
8+
with:
9+
flavor: "golang"
10+
use_default_dockerfiles: false
11+
secrets:
12+
gcp_project_id: ${{ secrets.GCP_PROJECT_ID }}
13+
gcp_cloud_run_sa: ${{ secrets.GCP_CLOUD_RUN_SA }}

Dockerfile.golang

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Note: This Dockerfile uses the vendor directory from the host machine.
2+
# Run 'go mod vendor' on the host machine before building this image.
3+
# Key files should be mounted at runtime to /app/keys using Docker secrets or volumes.
4+
5+
# Build stage
6+
FROM golang:1.24.5-alpine3.22 AS builder
7+
8+
# Install build dependencies
9+
RUN apk add --no-cache git make build-base
10+
11+
# Set working directory for the build
12+
WORKDIR /build
13+
14+
# Copy the source code including the vendor directory from host
15+
COPY . .
16+
17+
# Build the binary using the vendor directory from the host machine
18+
RUN go build -mod=vendor -o bridge ./cmd/bridge
19+
20+
# Final stage
21+
FROM alpine:3.22
22+
23+
# Install certificates and timezone data
24+
RUN apk add --no-cache ca-certificates tzdata
25+
26+
# Key files should be injected at runtime using Docker secrets or mounted volumes for security.
27+
28+
# Set working directory
29+
WORKDIR /app
30+
31+
# Copy the binary from the builder stage
32+
COPY --from=builder /build/bridge /app/bridge
33+
RUN chmod +x /app/bridge
34+
35+
# Create directories for data persistence
36+
RUN mkdir -p /app/logs /app/db /app/keys /app/config
37+
38+
# Verify binary exists (will fail build if missing)
39+
RUN ls -la /app/bridge
40+
41+
# Expose web server port
42+
EXPOSE 8080
43+
44+
# Expose P2P port as specified in config
45+
EXPOSE 10010
46+
47+
# Set the entrypoint
48+
ENTRYPOINT ["/app/bridge"]

0 commit comments

Comments
 (0)