Skip to content

Commit 691380d

Browse files
authored
ci: use crazymax/xgo:1.18.1 docker image as base (#17)
* ci: add Jenkins user to dockerfile Otherwise the `$HOME` variable is not set which results in: ``` + make test go test -v ./... failed to initialize build cache at /.cache/go-build: mkdir /.cache: permission denied Makefile:31: recipe for target 'test' failed ``` Signed-off-by: Jakub Sokołowski <jakub@status.im> * ci: use crazymax/xgo:1.18.1 docker image as base The old `xgo` image does not work: ``` ../../../../pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/common/test_utils.go:27:18: undefined: os.ReadFile note: module requires Go 1.17 Makefile:31: recipe for target 'test' failed ``` Signed-off-by: Jakub Sokołowski <jakub@status.im> Signed-off-by: Jakub Sokołowski <jakub@status.im>
1 parent eab69a1 commit 691380d

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ VERSION = $(shell cat VERSION)
1212
export GITHUB_USER ?= status-im
1313
export GITHUB_REPO ?= $(PROJECT_NAME)
1414

15-
export IMAGE_TAG ?= latest
15+
export IMAGE_TAG ?= xgo-1.18.1
1616
export IMAGE_NAME ?= statusteam/keycard-cli-ci:$(IMAGE_TAG)
1717

1818
export GO_PROJECT_PATH ?= github.com/$(GITHUB_USER)/$(GITHUB_REPO)
1919

20-
deps:
20+
deps: install-xgo install-github-release
2121
go version
22-
go install github.com/karalabe/xgo@latest
23-
go install github.com/aktau/github-release@latest
22+
23+
install-xgo:
24+
go install github.com/crazy-max/xgo@v0.23.0
25+
26+
install-github-release:
27+
go install github.com/aktau/github-release@v0.10.0
2428

2529
build:
2630
go build -o $(GOBIN)/$(BIN_NAME) -v -ldflags "-X main.version=$(VERSION)" .
@@ -35,10 +39,10 @@ docker-image:
3539

3640
build-platforms:
3741
xgo \
38-
-ldflags "-X main.version=$(VERSION)" \
39-
-out $(BIN_NAME) \
40-
-dest $(GOBIN) \
41-
-image $(IMAGE_NAME) \
42+
-ldflags="-X main.version=$(VERSION)" \
43+
-out=$(BIN_NAME) \
44+
-dest=$(GOBIN) \
45+
-docker-image=$(IMAGE_NAME) \
4246
-targets=$(XGO_TARGETS) .
4347

4448
release:

_assets/ci/Jenkinsfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ pipeline {
1313
}
1414

1515
environment {
16-
PROJECT = 'src/github.com/status-im/keycard-cli'
16+
PROJECT = "${env.WORKSPACE}/src/github.com/status-im/keycard-cli"
1717
GOPATH = "${env.WORKSPACE}"
1818
PATH = "${env.PATH}:${env.GOPATH}/bin"
1919
}
2020

2121
stages {
2222
stage('Prep') {
23-
steps { dir(env.PROJECT) {
23+
steps { dir(PROJECT) {
2424
sh 'make deps'
2525
} }
2626
}
@@ -29,7 +29,7 @@ pipeline {
2929
agent {
3030
docker {
3131
label 'linux'
32-
image 'statusteam/keycard-cli-ci:latest'
32+
image 'statusteam/keycard-cli-ci:xgo-1.18.1'
3333
args '--entrypoint=""' /* allows jenkins use cat */
3434
}
3535
}
@@ -40,25 +40,25 @@ pipeline {
4040
options {
4141
checkoutToSubdirectory('src/github.com/status-im/keycard-cli')
4242
}
43-
steps { dir(env.PROJECT) {
43+
steps { dir(PROJECT) {
4444
sh 'make test'
4545
} }
4646
}
4747

4848
stage('Build') {
49-
steps { script { dir(env.PROJECT) {
49+
steps { script { dir(PROJECT) {
5050
sh 'make build-platforms'
5151
} } }
5252
}
5353

5454
stage('Archive') {
55-
steps { dir(env.PROJECT) {
55+
steps { dir(PROJECT) {
5656
archiveArtifacts('build/bin/*')
5757
} }
5858
}
5959

6060
stage('Release') {
61-
steps { dir(env.PROJECT) {
61+
steps { dir(PROJECT) {
6262
withCredentials([usernamePassword(
6363
credentialsId: 'status-im-auto',
6464
usernameVariable: 'GITHUB_USER_NAME',

_assets/ci/Jenkinsfile.pr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pipeline {
22
agent {
33
docker {
44
label 'linux'
5-
image 'statusteam/keycard-cli-ci:latest'
5+
image 'statusteam/keycard-cli-ci:xgo-1.18.1'
66
args '--entrypoint=""' /* allows jenkins use cat */
77
}
88
}

_assets/docker/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM karalabe/xgo-1.13.x
1+
ARG GO_VERSION=1.18.1
2+
FROM crazymax/xgo:$GO_VERSION
23

34
ENV LANG=en_US.UTF-8 \
45
LC_ALL=en_US.UTF-8 \
@@ -10,7 +11,9 @@ RUN apt-get update \
1011
&& locale-gen ${LANG} \
1112
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1213

14+
# Jenkins user needs a specific UID/GID to work
15+
RUN groupadd -g 1001 jenkins \
16+
&& useradd --create-home -u 1001 -g 1001 jenkins
17+
1318
MAINTAINER Jakub Sokolowski "jakub@status.im"
1419
LABEL description="Image for building keycard-cli tool."
15-
16-
ENTRYPOINT ["/build.sh"]

_assets/docker/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
GIT_COMMIT = $(shell git rev-parse --short HEAD)
22
GIT_ROOT = $(shell git rev-parse --show-toplevel)
33

4-
IMAGE_TAG ?= latest
4+
GO_VERSION ?= 1.18.1
5+
IMAGE_TAG ?= xgo-$(GO_VERSION)
56
IMAGE_NAME ?= statusteam/keycard-cli-ci:$(IMAGE_TAG)
67

78
build:
89
docker build \
10+
--build-arg "GO_VERSION=$(GO_VERSION)" \
911
--label "commit=$(GIT_COMMIT)" \
1012
-t $(IMAGE_NAME) .
1113

0 commit comments

Comments
 (0)