File tree Expand file tree Collapse file tree 6 files changed +53
-16
lines changed Expand file tree Collapse file tree 6 files changed +53
-16
lines changed Original file line number Diff line number Diff line change 30
30
31
31
- uses : actions/setup-go@v5
32
32
with :
33
- go-version : ' ^1.17 '
33
+ go-version : ' ^1.21 '
34
34
- run : go install mvdan.cc/sh/v3/cmd/shfmt@latest
35
35
- run : $(go env GOPATH)/bin/shfmt -f . | grep -v 'vendor' | xargs $(go env GOPATH)/bin/shfmt -bn -ci -s -w
36
36
- name : suggester / shfmt
Original file line number Diff line number Diff line change 1
1
name : Scan docker
2
2
on : [pull_request]
3
+
4
+ env :
5
+ # Use docker.io for Docker Hub if empty
6
+ REGISTRY : docker.io
7
+
8
+ # github.repository as <account>/<repo>
9
+ IMAGE_NAME : perconalab/percona-server-mongodb-operator
10
+
3
11
jobs :
4
12
build :
5
13
name : Build
6
14
runs-on : ubuntu-latest
7
15
steps :
8
16
- name : Checkout code
9
17
10
- - name : Build an image from Dockerfile
18
+
19
+ - name : Set up QEMU
20
+ uses : docker/setup-qemu-action@v3
21
+
22
+ - name : Set up Docker Buildx
23
+ uses : docker/setup-buildx-action@v3
24
+
25
+ - name : Build an image from Dockerfile (linux/arm64)
11
26
run : |
12
- export IMAGE=perconalab/percona-server-mongodb-operator :${{ github.sha }}
27
+ export IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} :${{ github.sha }}-arm64
13
28
export DOCKER_PUSH=0
14
29
export DOCKER_SQUASH=0
30
+ export DOCKER_DEFAULT_PLATFORM='linux/arm64'
15
31
./e2e-tests/build
16
32
- name : Run Trivy vulnerability scanner
17
33
uses :
aquasecurity/[email protected]
18
34
with :
19
- image-ref : ' docker.io/perconalab/percona-server-mongodb-operator:${{ github.sha }}'
35
+ image-ref : ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64'
36
+ format : ' table'
37
+ exit-code : ' 1'
38
+ ignore-unfixed : true
39
+ vuln-type : ' os,library'
40
+ severity : ' CRITICAL,HIGH'
41
+
42
+ - name : Build an image from Dockerfile (linux/amd64)
43
+ run : |
44
+ export IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64
45
+ export DOCKER_PUSH=0
46
+ export DOCKER_SQUASH=0
47
+ export DOCKER_DEFAULT_PLATFORM='linux/amd64'
48
+ ./e2e-tests/build
49
+
50
+ - name : Run Trivy vulnerability scanner image (linux/amd64)
51
+ uses :
aquasecurity/[email protected]
52
+ with :
53
+ image-ref : ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64'
20
54
format : ' table'
21
55
exit-code : ' 1'
22
56
ignore-unfixed : true
Original file line number Diff line number Diff line change 7
7
steps :
8
8
- uses : actions/setup-go@v5
9
9
with :
10
- go-version : ' ^1.19 '
10
+ go-version : ' ^1.21 '
11
11
12
12
- name : go test
13
13
run : go test -v ./...
Original file line number Diff line number Diff line change 323
323
docker login -u '${USER}' -p '${PASS}'
324
324
export RELEASE=0
325
325
export IMAGE=\$ DOCKER_TAG
326
+ docker buildx create --use
326
327
./e2e-tests/build
327
328
docker logout
328
329
"
349
350
-v $WORKSPACE /src/github.com/percona/percona-server-mongodb-operator:/go/src/github.com/percona/percona-server-mongodb-operator \
350
351
-w /go/src/github.com/percona/percona-server-mongodb-operator \
351
352
-e GOFLAGS='-buildvcs=false' \
352
- golang:1.19 sh -c '
353
+ golang:1.21 sh -c '
353
354
go install github.com/google/[email protected] ;
354
355
/go/bin/go-licenses csv github.com/percona/percona-server-mongodb-operator/cmd/manager \
355
356
| cut -d , -f 3 \
377
378
-v $WORKSPACE/src/github.com/percona/percona-server-mongodb-operator:/go/src/github.com/percona/percona-server-mongodb-operator \
378
379
-w /go/src/github.com/percona/percona-server-mongodb-operator \
379
380
-e GOFLAGS='-buildvcs=false' \
380
- golang:1.19 sh -c 'go build -v -o percona-server-mongodb-operator github.com/percona/percona-server-mongodb-operator/cmd/manager'
381
+ golang:1.21 sh -c 'go build -v -o percona-server-mongodb-operator github.com/percona/percona-server-mongodb-operator/cmd/manager'
381
382
"
382
383
'''
383
384
Original file line number Diff line number Diff line change @@ -7,17 +7,16 @@ ARG GIT_COMMIT
7
7
ARG GIT_BRANCH
8
8
ARG GO_LDFLAGS
9
9
ARG GOOS=linux
10
- ARG GOARCH=amd64
11
10
ARG CGO_ENABLED=0
12
11
13
12
RUN go mod download \
14
13
&& mkdir -p build/_output/bin \
15
- && GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
14
+ && GOOS=$GOOS CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
16
15
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
17
16
-o build/_output/bin/percona-server-mongodb-operator \
18
17
cmd/manager/main.go \
19
18
&& cp -r build/_output/bin/percona-server-mongodb-operator /usr/local/bin/percona-server-mongodb-operator \
20
- && GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
19
+ && GOOS=$GOOS CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
21
20
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
22
21
-o build/_output/bin/mongodb-healthcheck \
23
22
cmd/mongodb-healthcheck/main.go \
Original file line number Diff line number Diff line change 14
14
if [[ ${DOCKER_SQUASH:- 1} == 1 ]]; then
15
15
squash=" --squash"
16
16
fi
17
+ if [[ ${DOCKER_PUSH:- 1} == 1 ]]; then
18
+ imgresult=" --push=true"
19
+ else
20
+ imgresult=" --load"
21
+ fi
17
22
18
23
build_operator () {
19
24
if [ " ${RELEASE:- 1} " = 0 ]; then
20
25
GO_LDFLAGS=" -race"
21
26
fi
22
27
23
28
export IMAGE
24
- export DOCKER_DEFAULT_PLATFORM=${DOCKER_DEFAULT_PLATFORM:- linux/ amd64}
29
+ export DOCKER_DEFAULT_PLATFORM=${DOCKER_DEFAULT_PLATFORM:- " linux/amd64,linux/arm64 " }
25
30
export GO_LDFLAGS=" -w -s -trimpath $GO_LDFLAGS "
26
31
pushd ${src_dir}
27
- docker build \
32
+ docker buildx build \
33
+ --platform $DOCKER_DEFAULT_PLATFORM \
28
34
--build-arg GIT_COMMIT=$GIT_COMMIT \
29
35
--build-arg GIT_BRANCH=$GIT_BRANCH \
30
36
--build-arg GO_LDFLAGS=" $GO_LDFLAGS " \
37
+ $imgresult \
31
38
$squash \
32
39
$no_cache \
33
40
-t " ${IMAGE} " -f build/Dockerfile .
34
41
popd
35
-
36
- if [ " ${DOCKER_PUSH:- 1} " = 1 ]; then
37
- docker push ${IMAGE}
38
- fi
39
42
}
40
43
41
44
until docker ps; do sleep 1; done
You can’t perform that action at this time.
0 commit comments