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

feat: add multiarch images for acpm #13

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
42 changes: 42 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release

on:
push:
tags:
- "v*"

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- id: meta
name: Docker meta
uses: docker/metadata-action@v5
with:
images: |
quay.io/3scale/aws-cvpn-pki-manager
tags: |
type=semver,pattern={{raw}}

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

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

- name: Login to Quay.io
uses: docker/login-action@v3
with:
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: quay.io
username: ${{ secrets.REGISTRY_USER }}

- name: Build and push
uses: docker/build-push-action@v6
with:
file: Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false
push: true
tags: ${{ steps.meta.outputs.tags }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Build
uses: docker/build-push-action@v6
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: quay.io/3scale/aws-cvpn-pki-manager:test
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
FROM debian:buster-slim
ARG release
FROM golang:1.23 as builder

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN apt update && apt -y install ca-certificates
COPY build/aws-cvpn-pki-manager_amd64_${release} /aws-cvpn-pki-manager
WORKDIR /app/
ADD . .
RUN CGO_ENABLED=0 GOOS=linux \
go build -ldflags '-extldflags "-static"' \
-o aws-cvpn-pki-manager cmd/main.go

# FROM debian:bullseye-slim
# RUN apt update && apt -y install ca-certificates

FROM alpine:3.20

RUN apk --no-cache add ca-certificates && update-ca-certificates

WORKDIR /app/

COPY --from=builder /app/aws-cvpn-pki-manager /app/aws-cvpn-pki-manager

EXPOSE 8080
ENTRYPOINT [ "/aws-cvpn-pki-manager", "server" ]
ENTRYPOINT [ "/app/aws-cvpn-pki-manager", "server" ]
47 changes: 34 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
RELEASE=$(shell cat RELEASE)

build: build/aws-cvpn-pki-manager_amd64_$(RELEASE)
.PHONY: help

build/aws-cvpn-pki-manager_amd64_$(RELEASE):
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o build/aws-cvpn-pki-manager_amd64_$(RELEASE) cmd/main.go
TAG ?= local
IMAGE ?= quay.io/3scale/aws-cvpn-pki-manager
CONTAINER_TOOL ?= podman

docker-build: build/aws-cvpn-pki-manager_amd64_$(RELEASE)
docker build . -t quay.io/3scale/aws-cvpn-pki-manager:v$(RELEASE) --build-arg release=$(RELEASE)
help:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort

docker-tag-latest: docker-build
docker tag quay.io/3scale/aws-cvpn-pki-manager:v$(RELEASE) quay.io/3scale/aws-cvpn-pki-manager:latest
get-new-release:
@hack/new-release.sh v$(TAG)

release: docker-tag-latest
docker push quay.io/3scale/aws-cvpn-pki-manager:v$(RELEASE)
docker push quay.io/3scale/aws-cvpn-pki-manager:latest
build-all-release: build

clean:
rm -rf build/*
push-all-release: push

build-all-latest: build-latest

push-all-latest: push-latest

build-all: build

build:
${CONTAINER_TOOL} manifest rm $(IMAGE):$(TAG) || echo "No manifest found"
${CONTAINER_TOOL} manifest create $(IMAGE):$(TAG)
${CONTAINER_TOOL} build \
--platform linux/amd64,linux/arm64 \
--manifest $(IMAGE):$(TAG) . -f Dockerfile

push:
${CONTAINER_TOOL} manifest push $(IMAGE):$(TAG)

build-latest: build
${CONTAINER_TOOL} tag $(IMAGE):$(TAG) $(IMAGE):latest

push-latest: build-latest
${CONTAINER_TOOL} push $(IMAGE):latest