Skip to content

Commit

Permalink
Add sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaedev committed Mar 29, 2024
1 parent cae780a commit c3aed6e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/harbor-multi-arch-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,22 @@ jobs:
CTX="BUILDBIN=true VERSIONTAG=${{ env.tag }} BASEIMAGETAG=${{ env.tag }} MULTIARCH=${MULTIARCH} "
CTX+="IMAGENAMESPACE=${IMAGENAMESPACE} BASEIMAGENAMESPACE=${BASEIMAGENAMESPACE} TRIVYFLAG=${TRIVYFLAG} "
CTX+="CHARTFLAG=${CHARTFLAG} NOTARYFLAG=${CHARTFLAG} IMAGELABELS=${IMAGELABELS}"
CTX+="CHARTFLAG=${CHARTFLAG} NOTARYFLAG=${NOTARYFLAG} IMAGELABELS=${IMAGELABELS}"
make versions_prepare ${CTX};
sudo make versions_prepare ${CTX};
case ${{ matrix.component }} in
core) make compile_core ${CTX} ;;
jobservice) make compile_jobservice ${CTX};;
registryctl) make compile_registryctl ${CTX};;
notary*) make compile_notary_migrate_patch ${CTX} ;;
standalone_db_migrator) make compile_standalone_db_migrator ${CTX} ;;
core) sudo make compile_core ${CTX} ;;
jobservice) sudo make compile_jobservice ${CTX};;
registryctl) sudo make compile_registryctl ${CTX};;
notary*) sudo make compile_notary_migrate_patch ${CTX} ;;
standalone_db_migrator) sudo make compile_standalone_db_migrator ${CTX} ;;
esac;
case ${{ matrix.component }} in
exporter) make build BUILDTARGET="_compile_and_build_exporter" ${CTX} ;;
registryctl) make build BUILDTARGET="_build_registry _build_registryctl" ${CTX} ;;
*) make build BUILDTARGET="_build_${{ matrix.component }}" ${CTX} ;;
exporter) sudo make build BUILDTARGET="_compile_and_build_exporter" ${CTX} ;;
registryctl) sudo make build BUILDTARGET="_build_registry _build_registryctl" ${CTX} ;;
*) sudo make build BUILDTARGET="_build_${{ matrix.component }}" ${CTX} ;;
esac;
harbor-building:
Expand Down
37 changes: 23 additions & 14 deletions template/harbor/v2.7.4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# compile_golangimage:
# compile from golang image
# for example: make compile_golangimage -e GOBUILDIMAGE= \
# golang:1.18.5
# golang:1.19.4
# compile_core, compile_jobservice: compile specific binary
#
# build: build Harbor docker images from photon baseimage
Expand Down Expand Up @@ -74,6 +74,8 @@ PORTAL_PATH=$(BUILDPATH)/src/portal
CHECKENVCMD=checkenv.sh

# parameters
# default is true
BUILD_PG96=true
REGISTRYSERVER=
REGISTRYPROJECTNAME=goharbor
DEVFLAG=true
Expand Down Expand Up @@ -111,6 +113,8 @@ NOTARYVERSION=v0.6.1
NOTARYMIGRATEVERSION=v4.11.0
TRIVYVERSION=v0.35.0
TRIVYADAPTERVERSION=v0.30.5
# TRIVYVERSION=v0.32.1
# TRIVYADAPTERVERSION=v0.30.2

# version of chartmuseum for pulling the source code
CHARTMUSEUM_SRC_TAG=v0.14.0
Expand Down Expand Up @@ -356,7 +360,7 @@ gen_apis: lint_apis


MOCKERY_IMAGENAME=$(IMAGENAMESPACE)/mockery
MOCKERY_VERSION=v2.14.0
MOCKERY_VERSION=v2.12.3
MOCKERY=$(RUNCONTAINER) ${MOCKERY_IMAGENAME}:${MOCKERY_VERSION}
MOCKERY_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/mockery/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg MOCKERY_VERSION=${MOCKERY_VERSION} -t ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) .

Expand Down Expand Up @@ -449,7 +453,7 @@ build:
-e TRIVY_DOWNLOAD_URL=$(TRIVY_DOWNLOAD_URL) -e TRIVY_ADAPTER_DOWNLOAD_URL=$(TRIVY_ADAPTER_DOWNLOAD_URL) \
-e PULL_BASE_FROM_DOCKERHUB=$(PULL_BASE_FROM_DOCKERHUB) -e BUILD_BASE=$(BUILD_BASE) \
-e REGISTRYUSER=$(REGISTRYUSER) -e REGISTRYPASSWORD=$(REGISTRYPASSWORD) \
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE)
-e PUSHBASEIMAGE=$(PUSHBASEIMAGE) -e BUILD_PG96=$(BUILD_PG96)

build_standalone_db_migrator: compile_standalone_db_migrator
make -f $(MAKEFILEPATH_PHOTON)/Makefile _build_standalone_db_migrator -e BASEIMAGETAG=$(BASEIMAGETAG) -e VERSIONTAG=$(VERSIONTAG)
Expand All @@ -463,12 +467,25 @@ build_base_docker:
@for name in $(BUILDBASETARGET); do \
echo $$name ; \
sleep 30 ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
if [ $$name == "db" ]; then \
make _build_base_db ; \
else \
$(DOCKERBUILD) --build-arg BUILD_PG96=$(BUILD_PG96) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/$$name/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
fi ; \
if [ "$(PUSHBASEIMAGE)" != "false" ] ; then \
$(PUSHSCRIPTPATH)/$(PUSHSCRIPTNAME) $(BASEIMAGENAMESPACE)/harbor-$$name-base:$(BASEIMAGETAG) $(REGISTRYUSER) $(REGISTRYPASSWORD) || exit 1; \
fi ; \
done

_build_base_db:
@if [ "$(BUILD_PG96)" = "true" ] ; then \
echo "build pg96 rpm package." ; \
cd $(MAKEFILEPATH_PHOTON)/db && $(MAKEFILEPATH_PHOTON)/db/rpm_builder.sh && cd - ; \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/db/Dockerfile.pg96 -t $(BASEIMAGENAMESPACE)/harbor-db-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
else \
$(DOCKERBUILD) --pull --no-cache -f $(MAKEFILEPATH_PHOTON)/db/Dockerfile.base -t $(BASEIMAGENAMESPACE)/harbor-db-base:$(BASEIMAGETAG) --label base-build-date=$(date +"%Y%m%d") . ; \
fi

pull_base_docker:
@for name in $(BUILDBASETARGET); do \
echo $$name ; \
Expand Down Expand Up @@ -530,20 +547,12 @@ misspell:
@echo checking misspell...
@find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error

# golangci-lint binary installation or refer to https://golangci-lint.run/usage/install/#local-installation
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
# go get -u github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
lint:
@echo checking lint
@echo $(GOLANGCI_LINT)
@cd ./src/; $(GOLANGCI_LINT) -v run ./... --timeout=10m;

# go install golang.org/x/vuln/cmd/govulncheck@latest
GOVULNCHECK := $(shell go env GOPATH)/bin/govulncheck
govulncheck:
@echo golang vulnerability check
@cd ./src/; $(GOVULNCHECK) ./...;

@cd ./src/; $(GOLANGCI_LINT) -v run ./...;

pushimage:
@echo "pushing harbor images ..."
Expand Down

0 comments on commit c3aed6e

Please sign in to comment.