Skip to content

Commit 7b0ed34

Browse files
authored
METAL-3573 ARM Support for db-operator docker image (kloeckner-i#7)
1 parent 542cb87 commit 7b0ed34

File tree

6 files changed

+514
-176
lines changed

6 files changed

+514
-176
lines changed

.github/workflows/build-and-test.yaml

Lines changed: 0 additions & 96 deletions
This file was deleted.

.github/workflows/image-publish.yaml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Publish Docker image
2+
3+
on:
4+
release:
5+
types: [published, edited]
6+
7+
env:
8+
dockerhub_user: kloeckneri
9+
manufacturer: kloeckner-i
10+
product_name: db-auth-gateway
11+
go_version: "1.18"
12+
go_os: linux
13+
main_go_path: ./cmd
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
include:
21+
- go_arch: "amd64"
22+
docker_arch: "amd64"
23+
- go_arch: "arm64"
24+
docker_arch: "arm64/v8"
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Setup go
30+
uses: actions/setup-go@v2
31+
with:
32+
go-version: ${{ env.go_version }}
33+
34+
- name: Compile Binary
35+
env:
36+
GOOS: ${{ env.go_os }}
37+
GOARCH: ${{ matrix.go_arch }}
38+
CGO_ENABLED: "0"
39+
run: |
40+
go build -tags build -o ${{ env.product_name }} ${{ env.main_go_path }}
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v2
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v1
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Login to Dockerhub
53+
uses: docker/login-action@v1
54+
with:
55+
username: ${{ env.dockerhub_user }}
56+
password: ${{ secrets.DOCKERHUB_TOKEN }}
57+
58+
- name: Set action link variable
59+
run: echo "LINK=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
60+
61+
- name: Build and export
62+
uses: docker/build-push-action@v3
63+
with:
64+
push: true
65+
context: .
66+
file: Dockerfile-ci
67+
platforms: ${{ env.go_os }}/${{ matrix.docker_arch }}
68+
tags: |
69+
${{ env.dockerhub_user }}/${{ env.product_name }}:latest-${{ matrix.go_arch }}
70+
${{ env.dockerhub_user }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-${{ matrix.go_arch }}
71+
ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:latest-${{ matrix.go_arch }}
72+
ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-${{ matrix.go_arch }}
73+
labels: |
74+
action_link=${{ env.LINK }}
75+
actor=${{ github.actor }}
76+
sha=${{ github.sha }}
77+
ref=${{ github.ref }}
78+
79+
push_to_ghcr:
80+
runs-on: ubuntu-latest
81+
needs: build
82+
steps:
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v2
85+
86+
- name: Login to GitHub Container Registry
87+
uses: docker/login-action@v2
88+
with:
89+
registry: ghcr.io
90+
username: ${{ github.actor }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Create a docker manifest for a versioned container
94+
run: |
95+
docker manifest create ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:${{ github.event.release.tag_name }} \
96+
--amend ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-amd64 \
97+
--amend ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-arm64
98+
99+
- name: Create a manifest for the latest container
100+
run: |
101+
docker manifest create ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:latest \
102+
--amend ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:latest-amd64 \
103+
--amend ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:latest-arm64
104+
105+
- name: Push the manifest
106+
run: |
107+
docker manifest push ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:${{ github.event.release.tag_name }}
108+
docker manifest push ghcr.io/${{ env.manufacturer }}/${{ env.product_name }}:latest
109+
110+
push_to_dockerhub:
111+
runs-on: ubuntu-latest
112+
needs: build
113+
steps:
114+
- name: Set up Docker Buildx
115+
uses: docker/setup-buildx-action@v2
116+
117+
- name: Login to GitHub Container Registry
118+
uses: docker/login-action@v2
119+
with:
120+
username: ${{ env.dockerhub_user }}
121+
password: ${{ secrets.DOCKERHUB_TOKEN }}
122+
123+
- name: Create a docker manifest for a versioned container
124+
run: |
125+
docker manifest create ${{ env.dockerhub_user }}/${{ env.product_name }}:${{ github.event.release.tag_name }} \
126+
--amend ${{ env.dockerhub_user }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-amd64 \
127+
--amend ${{ env.dockerhub_user }}/${{ env.product_name }}:${{ github.event.release.tag_name }}-arm64
128+
129+
- name: Create a manifest for the latest container
130+
run: |
131+
docker manifest create ${{ env.dockerhub_user }}/${{ env.product_name }}:latest \
132+
--amend ${{ env.dockerhub_user }}/${{ env.product_name }}:latest-amd64 \
133+
--amend ${{ env.dockerhub_user }}/${{ env.product_name }}:latest-arm64
134+
135+
- name: Push the manifest
136+
run: |
137+
docker manifest push ${{ env.dockerhub_user }}/${{ env.product_name }}:${{ github.event.release.tag_name }}
138+
docker manifest push ${{ env.dockerhub_user }}/${{ env.product_name }}:latest
139+

.github/workflows/test.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Check Code Style
19+
uses: golangci/golangci-lint-action@v2
20+
with:
21+
version: v1.46.2
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
needs: lint
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v1
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v1
35+
36+
- name: Test
37+
env:
38+
MOCK_ADDRESS: 127.0.0.1
39+
run: |
40+
# Separated to ensure the reset_mock target is executed between stages.
41+
make test
42+
make e2e
43+
44+
- name: Upload Test Logs
45+
uses: actions/upload-artifact@v2
46+
if: failure()
47+
with:
48+
name: test-logs
49+
path: target/db-auth-gateway.log
50+
51+
- name: Collect Docker Logs
52+
if: failure()
53+
uses: jwalton/gh-docker-logs@v1
54+
with:
55+
dest: "./logs"
56+
57+
- name: Tar Docker Logs
58+
if: failure()
59+
run: tar cvzf ./logs.tgz ./logs
60+
61+
- name: Upload Docker Logs
62+
uses: actions/upload-artifact@v2
63+
if: failure()
64+
with:
65+
name: docker-logs
66+
path: ./logs.tgz

Dockerfile-ci

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM alpine:3.15.0
2+
LABEL maintainer="[email protected]"
3+
4+
COPY ./db-auth-gateway /usr/local/bin/db-auth-gateway
5+
COPY ./LICENSE /LICENSE
6+
7+
RUN addgroup -g 65532 -S gateway \
8+
&& adduser -u 65532 -S gateway -G gateway
9+
10+
USER 65532
11+
12+
ENTRYPOINT [ "/usr/local/bin/db-auth-gateway" ]

go.mod

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
module github.com/kloeckner-i/db-auth-gateway
22

3-
go 1.15
3+
go 1.18
44

55
require (
6-
cloud.google.com/go v0.78.0 // indirect
7-
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
86
github.com/jackc/pgx/v4 v4.11.0
9-
github.com/magefile/mage v1.11.0 // indirect
10-
github.com/prometheus/client_golang v1.3.0
11-
github.com/sirupsen/logrus v1.8.0
12-
github.com/spf13/cobra v1.1.3
7+
github.com/prometheus/client_golang v1.12.2
8+
github.com/sirupsen/logrus v1.8.1
9+
github.com/spf13/cobra v1.4.0
1310
github.com/stretchr/testify v1.7.0
11+
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401
12+
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
13+
google.golang.org/api v0.81.0
14+
)
15+
16+
require (
17+
cloud.google.com/go/compute v1.6.1 // indirect
18+
github.com/beorn7/perks v1.0.1 // indirect
19+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
20+
github.com/davecgh/go-spew v1.1.1 // indirect
21+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
22+
github.com/golang/protobuf v1.5.2 // indirect
23+
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
24+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
25+
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
26+
github.com/jackc/pgconn v1.8.1 // indirect
27+
github.com/jackc/pgio v1.0.0 // indirect
28+
github.com/jackc/pgpassfile v1.0.0 // indirect
29+
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
30+
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
31+
github.com/jackc/pgtype v1.7.0 // indirect
32+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
33+
github.com/pmezard/go-difflib v1.0.0 // indirect
34+
github.com/prometheus/client_model v0.2.0 // indirect
35+
github.com/prometheus/common v0.34.0 // indirect
36+
github.com/prometheus/procfs v0.7.3 // indirect
37+
github.com/spf13/pflag v1.0.5 // indirect
38+
go.opencensus.io v0.23.0 // indirect
1439
golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e // indirect
15-
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99
16-
golang.org/x/sys v0.0.0-20210305034016-7844c3c200c3 // indirect
17-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
18-
golang.org/x/text v0.3.6 // indirect
19-
google.golang.org/api v0.40.0
20-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
40+
golang.org/x/net v0.0.0-20220524220425-1d687d428aca // indirect
41+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
42+
golang.org/x/text v0.3.7 // indirect
43+
google.golang.org/appengine v1.6.7 // indirect
44+
google.golang.org/genproto v0.0.0-20220525015930-6ca3db687a9d // indirect
45+
google.golang.org/grpc v1.46.2 // indirect
46+
google.golang.org/protobuf v1.28.0 // indirect
2147
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
2248
)

0 commit comments

Comments
 (0)