Skip to content

Commit 6b3f233

Browse files
authored
Merge pull request #1267 from shahidhs-ibm/s390x-multiarch
Add support to multi architecture docker image using github action
2 parents a8697b2 + cf63dcb commit 6b3f233

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and publish cfssl docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build-and-push-image:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get tag
21+
id: cfssl
22+
run: echo "::set-output name=tag::$(git describe --tags HEAD)"
23+
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v2
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
- name: Log in to the Docker hub
31+
uses: docker/login-action@v2
32+
with:
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
36+
- name: Build and push
37+
uses: docker/build-push-action@v3
38+
with:
39+
context: .
40+
platforms: linux/amd64,linux/arm64,linux/s390x
41+
push: true
42+
tags: cfssl:${{ steps.cfssl.outputs.tag }}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
FROM golang:1.16.15@sha256:35fa3cfd4ec01a520f6986535d8f70a5eeef2d40fb8019ff626da24989bdd4f1
1+
FROM --platform=${BUILDPLATFORM} golang:1.19.3
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
25

36
WORKDIR /workdir
47
COPY . /workdir
58

69
RUN git clone https://github.com/cloudflare/cfssl_trust.git /etc/cfssl && \
710
make clean && \
8-
make all && cp bin/* /usr/bin/
11+
GOOS=${TARGETOS} GOARCH=${TARGETARCH} make all && cp bin/* /usr/bin/
912

1013
EXPOSE 8888
1114

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ all: bin/cfssl bin/cfssl-bundle bin/cfssl-certinfo bin/cfssl-newkey bin/cfssl-sc
99

1010
bin/%: $(shell find . -type f -name '*.go')
1111
@mkdir -p $(dir $@)
12+
ifneq ($(and $(TARGETOS),$(TARGETARCH)),)
13+
GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F)
14+
else
1215
go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F)
16+
endif
1317

1418
.PHONY: install
1519
install: install-cfssl install-cfssl-bundle install-cfssl-certinfo install-cfssl-newkey install-cfssl-scan install-cfssljson install-mkbundle install-multirootca
@@ -25,7 +29,11 @@ serve:
2529

2630
bin/goose: $(shell find vendor -type f -name '*.go')
2731
@mkdir -p $(dir $@)
32+
ifneq ($(and $(TARGETOS),$(TARGETARCH)),)
33+
GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -o $@ ./vendor/bitbucket.org/liamstask/goose/cmd/goose
34+
else
2835
go build -o $@ ./vendor/bitbucket.org/liamstask/goose/cmd/goose
36+
endif
2937

3038
.PHONY: clean
3139
clean:

0 commit comments

Comments
 (0)