Skip to content

Commit 610a8af

Browse files
committed
Test arm build
1 parent da70336 commit 610a8af

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

.github/workflows/test.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- feature/arm-build
7+
8+
jobs:
9+
test-arm-build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Setup go
15+
uses: actions/setup-go@v4
16+
with:
17+
go-version: '1.20'
18+
check-latest: true
19+
- run: go version
20+
- name: Run build
21+
run: make clean build
22+
- name: Run test
23+
run: make test
24+
- name: Docker meta
25+
id: meta
26+
uses: docker/metadata-action@v4
27+
with:
28+
images: |
29+
grepplabs/mqtt-proxy
30+
tags: |
31+
type=ref,event=branch
32+
type=ref,event=pr
33+
type=semver,pattern={{version}}
34+
type=semver,pattern={{major}}.{{minor}}
35+
type=semver,pattern={{major}}
36+
type=sha
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v2
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v2
41+
- name: Login to DockerHub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKERHUB_USERNAME }}
45+
password: ${{ secrets.DOCKERHUB_TOKEN }}
46+
- name: Build and push
47+
uses: docker/build-push-action@v4
48+
with:
49+
context: .
50+
platforms: linux/amd64,linux/arm64
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.17 as builder
1+
FROM golang:1.20-alpine3.17 as builder
22

33
RUN apk add alpine-sdk ca-certificates
44

@@ -11,7 +11,7 @@ ADD . "/code"
1111
# https://github.com/confluentinc/confluent-kafka-go: When building your application for Alpine Linux (musl libc) you must pass -tags musl to go get, go build, etc.
1212
RUN make BINARY=mqtt-proxy BUILD_FLAGS="-tags musl" GOOS=${TARGETOS} GOARCH=${TARGETARCH} build
1313

14-
FROM --platform=$BUILDPLATFORM alpine:3.17
14+
FROM alpine:3.17
1515
RUN apk add ca-certificates
1616
COPY --from=builder /code/mqtt-proxy /mqtt-proxy
1717
ENTRYPOINT ["/mqtt-proxy"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ os-build:
6262

6363
.PHONY: docker-build
6464
docker-build:
65-
docker buildx build --build-arg BUILDPLATFORM=$(BUILDPLATFORM) --build-arg TARGETARCH=$(GOARCH) -f Dockerfile -t $(LOCAL_IMAGE) .
65+
docker buildx build --platform $(BUILDPLATFORM) --build-arg TARGETARCH=$(GOARCH) --build-arg TARGETOS=$(GOOS) -f Dockerfile -t $(LOCAL_IMAGE) .
6666

6767
.PHONY: docker-push
6868
docker-push:

cmd/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"crypto/tls"
55
"fmt"
6+
"runtime"
67

78
"github.com/grepplabs/mqtt-proxy/apis"
89
authinst "github.com/grepplabs/mqtt-proxy/pkg/auth/instrument"
@@ -32,7 +33,7 @@ func runServer(
3233
registry *prometheus.Registry,
3334
cfg *config.Server,
3435
) error {
35-
logger.WithField("version", version.Version).WithField("branch", version.Branch).WithField("revision", version.Revision).Infof("starting mqtt-proxy")
36+
logger.WithField("version", version.Version).WithField("branch", version.Branch).WithField("revision", version.Revision).Infof("starting mqtt-proxy on %s/%s", runtime.GOOS, runtime.GOARCH)
3637

3738
err := cfg.Validate()
3839
if err != nil {

0 commit comments

Comments
 (0)