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

ci: use crazymax/xgo:1.18.1 docker image as base #17

Merged
merged 2 commits into from
Nov 9, 2022
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
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ VERSION = $(shell cat VERSION)
export GITHUB_USER ?= status-im
export GITHUB_REPO ?= $(PROJECT_NAME)

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

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

deps:
deps: install-xgo install-github-release
go version
go install github.com/karalabe/xgo@latest
go install github.com/aktau/github-release@latest

install-xgo:
go install github.com/crazy-max/[email protected]

install-github-release:
go install github.com/aktau/[email protected]

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

build-platforms:
xgo \
-ldflags "-X main.version=$(VERSION)" \
-out $(BIN_NAME) \
-dest $(GOBIN) \
-image $(IMAGE_NAME) \
-ldflags="-X main.version=$(VERSION)" \
-out=$(BIN_NAME) \
-dest=$(GOBIN) \
-docker-image=$(IMAGE_NAME) \
-targets=$(XGO_TARGETS) .

release:
Expand Down
14 changes: 7 additions & 7 deletions _assets/ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ pipeline {
}

environment {
PROJECT = 'src/github.com/status-im/keycard-cli'
PROJECT = "${env.WORKSPACE}/src/github.com/status-im/keycard-cli"
GOPATH = "${env.WORKSPACE}"
PATH = "${env.PATH}:${env.GOPATH}/bin"
}

stages {
stage('Prep') {
steps { dir(env.PROJECT) {
steps { dir(PROJECT) {
sh 'make deps'
} }
}
Expand All @@ -29,7 +29,7 @@ pipeline {
agent {
docker {
label 'linux'
image 'statusteam/keycard-cli-ci:latest'
image 'statusteam/keycard-cli-ci:xgo-1.18.1'
args '--entrypoint=""' /* allows jenkins use cat */
}
}
Expand All @@ -40,25 +40,25 @@ pipeline {
options {
checkoutToSubdirectory('src/github.com/status-im/keycard-cli')
}
steps { dir(env.PROJECT) {
steps { dir(PROJECT) {
sh 'make test'
} }
}

stage('Build') {
steps { script { dir(env.PROJECT) {
steps { script { dir(PROJECT) {
sh 'make build-platforms'
} } }
}

stage('Archive') {
steps { dir(env.PROJECT) {
steps { dir(PROJECT) {
archiveArtifacts('build/bin/*')
} }
}

stage('Release') {
steps { dir(env.PROJECT) {
steps { dir(PROJECT) {
withCredentials([usernamePassword(
credentialsId: 'status-im-auto',
usernameVariable: 'GITHUB_USER_NAME',
Expand Down
2 changes: 1 addition & 1 deletion _assets/ci/Jenkinsfile.pr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent {
docker {
label 'linux'
image 'statusteam/keycard-cli-ci:latest'
image 'statusteam/keycard-cli-ci:xgo-1.18.1'
args '--entrypoint=""' /* allows jenkins use cat */
}
}
Expand Down
9 changes: 6 additions & 3 deletions _assets/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM karalabe/xgo-1.13.x
ARG GO_VERSION=1.18.1
FROM crazymax/xgo:$GO_VERSION

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

# Jenkins user needs a specific UID/GID to work
RUN groupadd -g 1001 jenkins \
&& useradd --create-home -u 1001 -g 1001 jenkins

MAINTAINER Jakub Sokolowski "[email protected]"
LABEL description="Image for building keycard-cli tool."

ENTRYPOINT ["/build.sh"]
4 changes: 3 additions & 1 deletion _assets/docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
GIT_COMMIT = $(shell git rev-parse --short HEAD)
GIT_ROOT = $(shell git rev-parse --show-toplevel)

IMAGE_TAG ?= latest
GO_VERSION ?= 1.18.1
IMAGE_TAG ?= xgo-$(GO_VERSION)
IMAGE_NAME ?= statusteam/keycard-cli-ci:$(IMAGE_TAG)

build:
docker build \
--build-arg "GO_VERSION=$(GO_VERSION)" \
--label "commit=$(GIT_COMMIT)" \
-t $(IMAGE_NAME) .

Expand Down