Skip to content

Commit

Permalink
bump golang1.20.6 on release-2.8.0& build golang based on photon (#18990
Browse files Browse the repository at this point in the history
)

Signed-off-by: yminer <yminer@vmware.com>

remove build_golang in ci script

fix typo

try to remove tdnf install make in registry/dockerfile.binary

optimize golang image
  • Loading branch information
MinerYang authored Jul 27, 2023
1 parent ec44426 commit 19d6963
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.20.4
go-version: 1.20.6
id: go
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbo
| 2.5 | 1.17.7 |
| 2.6 | 1.18.6 |
| 2.7 | 1.19.4 |
| 2.8 | 1.20.4 |
| 2.8 | 1.20.6 |

Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions.

Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test
GODEP=$(GOTEST) -i
GOFMT=gofmt -w
GOBUILDIMAGE=golang:1.20.4
GOVERSION=1.20.6
GOBUILDIMAGE=goharbor/golang:$(GOVERSION)
PUSHGOIMAGE=false
GOBUILDPATHINCONTAINER=/harbor

# go build
Expand Down Expand Up @@ -471,6 +473,16 @@ package_offline: update_prepare_version compile build
@rm -rf $(HARBORPKG)
@echo "Done."


build_golang:
@echo "build goharbor/golang image"
$(DOCKERBUILD) --build-arg GOVERSION=$(GOVERSION) -f $(MAKEPATH)/photon/golang/Dockerfile -t $(GOBUILDIMAGE) .
@if [ "$(PUSHGOIMAGE)" = "true" ] ; then \
echo "push goharbor/golang image"; \
docker login -u $(REGISTRYUSER) -p $(REGISTRYPASSWORD) ; \
docker push $(GOBUILDIMAGE); \
fi; \

gosec:
#go get github.com/securego/gosec/cmd/gosec
#go get github.com/dghubble/sling
Expand Down
21 changes: 21 additions & 0 deletions make/photon/golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM photon:4.0

ARG GOVERSION

ENV PATH /usr/local/go/bin:$PATH

ENV GOLANG_VERSION ${GOVERSION}

RUN set eux; \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
wget -O go.tgz "$url"; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
go version

ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH"
WORKDIR $GOPATH

RUN tdnf install make libstdc++ -y
2 changes: 1 addition & 1 deletion make/photon/registry/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.4
FROM goharbor/golang:1.20.6

ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs
Expand Down
2 changes: 1 addition & 1 deletion make/photon/trivy-adapter/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.4
FROM goharbor/golang:1.20.6

ADD . /go/src/github.com/aquasecurity/harbor-scanner-trivy/
WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy/
Expand Down
2 changes: 1 addition & 1 deletion make/photon/trivy-adapter/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEMP=$(mktemp -d ${TMPDIR-/tmp}/trivy-adapter.XXXXXX)
git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP
cd $TEMP; git checkout $VERSION; cd -

echo "Building Trivy adapter binary based on golang:1.20.4..."
echo "Building Trivy adapter binary based on goharbor/golang:1.20.6..."
cp Dockerfile.binary $TEMP
docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP

Expand Down
4 changes: 2 additions & 2 deletions tests/ci/distro_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -x

set -e

sudo make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=golang:1.20.4 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false
sudo make package_offline GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=golang:1.20.4 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false
sudo make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.20.6 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false
sudo make package_offline GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.20.6 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false

0 comments on commit 19d6963

Please sign in to comment.