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

chore(ci/docker): include arm64 #491

Merged
merged 1 commit into from
Nov 20, 2023
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
14 changes: 9 additions & 5 deletions .github/workflows/publish_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: create docker images
run: |
make docker-create-all
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'

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

- name: push docker images
- name: build and push docker images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
make docker-push-latest
make docker-build-push-latest
16 changes: 10 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
go-version-file: 'go.mod'
cache: true
check-latest: true

- name: run goreleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5
with:
Expand All @@ -45,13 +45,17 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: create docker images
run: |
make docker-create-all
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'

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

- name: push docker images
- name: build and push docker images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
make docker-push
make docker-build-push
82 changes: 41 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BUILD_LDFLAGS := -s -w
BUILD_LDFLAGS += -X github.com/target/flottbot/version.Version=${VERSION}
GOLANGCI_LINT_VERSION := "v1.55.2"
PACKAGES := $(shell go list ./... | grep -v /config-example/)
PLATFORM := "linux/amd64,linux/arm64"

DOCKER_IMAGE ?= "target/flottbot"
DOCKER_FLAVORS ?= golang ruby python
Expand Down Expand Up @@ -76,29 +77,6 @@ build: clean
# ┌┬┐┌─┐┌─┐┬┌─┌─┐┬─┐
# │││ ││ ├┴┐├┤ ├┬┘
# ─┴┘└─┘└─┘┴ ┴└─┘┴└─
.PHONY: docker-base
docker-base:
@echo "Creating base $@ image"
@docker build \
--build-arg "VERSION=$(VERSION)" \
-f "./docker/Dockerfile" \
-t $(DOCKER_IMAGE):$(VERSION) \
-t $(DOCKER_IMAGE):latest .

.PHONY: docker-flavors
docker-flavors:
@for flavor in $(DOCKER_FLAVORS); do \
echo "Creating image for $$flavor"; \
docker build \
--build-arg "VERSION=$(VERSION)" \
-f "./docker/Dockerfile.$$flavor" \
-t $(DOCKER_IMAGE):$$flavor \
-t $(DOCKER_IMAGE):$$flavor-$(VERSION) .; \
done

.PHONY: docker-create-all
docker-create-all: docker-base docker-flavors

.PHONY: docker-login
docker-login:
ifndef DOCKER_USERNAME
Expand All @@ -109,28 +87,50 @@ docker-login:
@echo "Logging into docker hub"
@echo "$$DOCKER_PASSWORD" | docker login -u $$DOCKER_USERNAME --password-stdin

.PHONY: docker-push
docker-push: docker-login
@echo "Pushing $(DOCKER_IMAGE):$(VERSION) and :latest to docker hub"
@docker push $(DOCKER_IMAGE):$(VERSION)
@docker push $(DOCKER_IMAGE):latest

.PHONY: docker-build-push-latest
docker-build-push-latest: docker-login
@echo "Building and pushing latest to docker hub..."
@echo "Building and pushing $(DOCKER_IMAGE):latest"
@docker buildx build \
--progress=plain \
--build-arg "VERSION=$(VERSION)" \
--platform $(PLATFORM) \
--file "./docker/Dockerfile" \
--tag $(DOCKER_IMAGE):latest \
--push .
@for flavor in $(DOCKER_FLAVORS); do \
echo "Pushing $(DOCKER_IMAGE):$$flavor to docker hub"; \
docker push $(DOCKER_IMAGE):$$flavor; \
docker push $(DOCKER_IMAGE):$$flavor-$(VERSION); \
echo "Building and pushing $(DOCKER_IMAGE):$$flavor"; \
docker buildx build \
--progress=plain \
--build-arg "VERSION=$(VERSION)" \
--platform $(PLATFORM) \
--file "./docker/Dockerfile.$$flavor" \
--tag $(DOCKER_IMAGE):$$flavor \
--push .;
done

.PHONY: docker-push-latest
docker-push-latest: docker-login
@echo "Pushing to :latest images to docker hub..."

@echo "Pushing $(DOCKER_IMAGE):latest"
@docker push $(DOCKER_IMAGE):latest

.PHONY: docker-build-push
docker-build-push-latest: docker-login
@echo "Building and pushing $(VERSION) to docker hub..."
@echo "Building and pushing $(DOCKER_IMAGE):$(VERSION)"
@docker buildx build \
--progress=plain \
--build-arg "VERSION=$(VERSION)" \
--platform $(PLATFORM) \
--file "./docker/Dockerfile" \
--tag $(DOCKER_IMAGE):$(VERSION) \
--tag $(DOCKER_IMAGE):latest \
--push .
@for flavor in $(DOCKER_FLAVORS); do \
echo "Pushing $(DOCKER_IMAGE):$$flavor to docker hub"; \
docker push $(DOCKER_IMAGE):$$flavor; \
echo "Building and pushing $(DOCKER_IMAGE):$$flavor-$(VERSION)"; \
docker buildx build \
--progress=plain \
--build-arg "VERSION=$(VERSION)" \
--platform $(PLATFORM) \
--file "./docker/Dockerfile.$$flavor" \
--tag $(DOCKER_IMAGE):$$flavor-$(VERSION) \
--tag $(DOCKER_IMAGE):$$flavor \
--push .;
done

# ┬─┐┬ ┬┌┐┌
Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION

# needed for vcs feature introduced in go 1.18+
Expand All @@ -12,7 +15,7 @@ RUN go mod download

COPY / .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -a -ldflags "-s -w -X github.com/target/flottbot/version.Version=${VERSION}" \
-o flottbot ./cmd/flottbot

Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile.golang
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION

# needed for vcs feature introduced in go 1.18+
Expand All @@ -12,7 +15,7 @@ RUN go mod download

COPY / .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -a -ldflags "-s -w -X github.com/target/flottbot/version.Version=${VERSION}" \
-o flottbot ./cmd/flottbot

Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION

# needed for vcs feature introduced in go 1.18+
Expand All @@ -12,7 +15,7 @@ RUN go mod download

COPY / .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -a -ldflags "-s -w -X github.com/target/flottbot/version.Version=${VERSION}" \
-o flottbot ./cmd/flottbot

Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile.ruby
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.4-alpine@sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION

# needed for vcs feature introduced in go 1.18+
Expand All @@ -12,7 +15,7 @@ RUN go mod download

COPY / .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -a -ldflags "-s -w -X github.com/target/flottbot/version.Version=${VERSION}" \
-o flottbot ./cmd/flottbot

Expand Down