Skip to content

Commit

Permalink
Merge pull request #1267 from shahidhs-ibm/s390x-multiarch
Browse files Browse the repository at this point in the history
Add support to multi architecture docker image using github action
  • Loading branch information
nickysemenza authored Mar 21, 2023
2 parents a8697b2 + cf63dcb commit 6b3f233
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and publish cfssl docker image

on:
push:
tags:
- 'v*.*.*'

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get tag
id: cfssl
run: echo "::set-output name=tag::$(git describe --tags HEAD)"

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: cfssl:${{ steps.cfssl.outputs.tag }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
FROM golang:1.16.15@sha256:35fa3cfd4ec01a520f6986535d8f70a5eeef2d40fb8019ff626da24989bdd4f1
FROM --platform=${BUILDPLATFORM} golang:1.19.3

ARG TARGETOS
ARG TARGETARCH

WORKDIR /workdir
COPY . /workdir

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

EXPOSE 8888

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ all: bin/cfssl bin/cfssl-bundle bin/cfssl-certinfo bin/cfssl-newkey bin/cfssl-sc

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

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

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

.PHONY: clean
clean:
Expand Down

0 comments on commit 6b3f233

Please sign in to comment.