Skip to content

Commit cda6bf5

Browse files
Fix Dockerfile and add Build Image to GH Actions (#561)
* Remove specified git version to avoid downgrades breaking docker build * Add build docker image to unit test action * Update to use current branch instead of commit for docker image build * Update docker image script to push image if env var is set * Add new line to build image script * Update scripts/constants.sh Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org> * Update docker login * Update build image action * Update gh action * checkout for docker image build * Set build image ID in gh action with github.ref_name * Separate CI and release * remove extra copy * Update name * Update variable used in build image id * Update set var * Update dockerhub repo * Revert dockerhub repo name chnge and use Subnet-EVM in tag name --------- Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org>
1 parent 8b776d6 commit cda6bf5

File tree

5 files changed

+65
-44
lines changed

5 files changed

+65
-44
lines changed

.github/workflows/lint-tests-release.yml renamed to .github/workflows/ci.yml

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build + test + release
1+
name: Build + Test + Lint
22

33
on:
44
push:
@@ -43,6 +43,16 @@ jobs:
4343
- run: ./scripts/coverage.sh
4444
shell: bash
4545

46+
build_image:
47+
name: Build Docker Image
48+
runs-on: ubuntu-20.04
49+
steps:
50+
- uses: actions/checkout@v3
51+
- run: echo ${{ secrets.docker_pass }} | docker login --username ${{ secrets.docker_username }} --password-stdin
52+
shell: bash
53+
- run: CURRENT_BRANCH=${{ github.head_ref || github.ref_name }} PUSH_DOCKER_IMAGE=true ./scripts/build_image.sh
54+
shell: bash
55+
4656
e2e_test:
4757
name: e2e tests
4858
runs-on: ubuntu-latest
@@ -71,44 +81,3 @@ jobs:
7181
- name: Run E2E Tests
7282
shell: bash
7383
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego DATA_DIR=/tmp/e2e-test/data ./scripts/run_ginkgo.sh
74-
75-
release:
76-
# needs: [lint_test, unit_test, e2e_test, simulator_test]
77-
runs-on: ubuntu-20.04
78-
steps:
79-
- name: Git checkout
80-
uses: actions/checkout@v3
81-
with:
82-
fetch-depth: 0
83-
path: subnet-evm
84-
- name: Set up Go
85-
uses: actions/setup-go@v3
86-
with:
87-
go-version: "1.19"
88-
- name: Set up arm64 cross compiler
89-
run: |
90-
sudo apt-get -y update
91-
sudo apt-get -y install gcc-aarch64-linux-gnu
92-
- name: Checkout osxcross
93-
uses: actions/checkout@v2
94-
with:
95-
repository: tpoechtrager/osxcross
96-
path: osxcross
97-
- name: Build osxcross
98-
run: |
99-
sudo apt-get -y install clang llvm-dev libxml2-dev uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio libbz2-dev
100-
cd osxcross
101-
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz -O tarballs/MacOSX11.3.sdk.tar.xz
102-
echo cd4f08a75577145b8f05245a2975f7c81401d75e9535dcffbb879ee1deefcbf4 tarballs/MacOSX11.3.sdk.tar.xz | sha256sum -c -
103-
UNATTENDED=1 ./build.sh
104-
echo $PWD/target/bin >> $GITHUB_PATH
105-
- name: Run GoReleaser
106-
uses: goreleaser/goreleaser-action@v2
107-
with:
108-
distribution: goreleaser
109-
version: latest
110-
args: release --clean
111-
workdir: ./subnet-evm/
112-
env:
113-
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
114-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
release:
10+
# needs: [lint_test, unit_test, e2e_test, simulator_test]
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Git checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
path: subnet-evm
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: "1.19"
22+
- name: Set up arm64 cross compiler
23+
run: |
24+
sudo apt-get -y update
25+
sudo apt-get -y install gcc-aarch64-linux-gnu
26+
- name: Checkout osxcross
27+
uses: actions/checkout@v2
28+
with:
29+
repository: tpoechtrager/osxcross
30+
path: osxcross
31+
- name: Build osxcross
32+
run: |
33+
sudo apt-get -y install clang llvm-dev libxml2-dev uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio libbz2-dev
34+
cd osxcross
35+
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz -O tarballs/MacOSX11.3.sdk.tar.xz
36+
echo cd4f08a75577145b8f05245a2975f7c81401d75e9535dcffbb879ee1deefcbf4 tarballs/MacOSX11.3.sdk.tar.xz | sha256sum -c -
37+
UNATTENDED=1 ./build.sh
38+
echo $PWD/target/bin >> $GITHUB_PATH
39+
- name: Run GoReleaser
40+
uses: goreleaser/goreleaser-action@v2
41+
with:
42+
distribution: goreleaser
43+
version: latest
44+
args: release --clean
45+
workdir: ./subnet-evm/
46+
env:
47+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG AVALANCHE_VERSION
66

77
# ============= Compilation Stage ================
88
FROM golang:1.19.6-buster AS builder
9-
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 git=1:2.20.1-2+deb10u3 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64
9+
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64
1010

1111
WORKDIR /build
1212

scripts/build_image.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ docker build -t "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" "$SUBNET_EVM_PATH" -f "$SUBNET
1818
--build-arg AVALANCHE_VERSION="$AVALANCHEGO_VERSION" \
1919
--build-arg SUBNET_EVM_COMMIT="$SUBNET_EVM_COMMIT" \
2020
--build-arg CURRENT_BRANCH="$CURRENT_BRANCH"
21+
22+
if [[ ${PUSH_DOCKER_IMAGE:-""} == "true" ]]; then
23+
docker push $DOCKERHUB_REPO:$BUILD_IMAGE_ID
24+
fi

scripts/constants.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
echo "Using branch: ${CURRENT_BRANCH}"
2828

29-
BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"$AVALANCHEGO_VERSION-$SUBNET_EVM_COMMIT_ID"}
29+
BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"${AVALANCHEGO_VERSION}-Subnet-EVM-${CURRENT_BRANCH}"}
3030

3131
# Static compilation
3232
STATIC_LD_FLAGS=''

0 commit comments

Comments
 (0)