Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: add harbor arm build parameters #17968

Conversation

Jeremy-boo
Copy link

@Jeremy-boo Jeremy-boo commented Dec 11, 2022

Signed-off-by: Jeremy-boo bozhu@alauda.io

Thank you for contributing to Harbor!

Comprehensive Summary of your change

Add support for multi-arch platform builds

Issue being fixed

Fixes #(issue)

  • Require image for ARM64 architecture Require image for ARM64 architecture  #16959
  • arm64 supported #14330
    Please indicate you've done the following:
  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@@ -13,6 +13,8 @@ env:
REDIS_HOST: localhost
REG_VERSION: v2.7.1-patch-2819-2553
UI_BUILDER_VERSION: 1.6.0
ARCH: amd64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add support for multi-architecture parameters,default is amd64.

@@ -121,13 +121,19 @@ CHARTMUSEUMVERSION=$(CHARTMUSEUM_SRC_TAG)-redis
# version of registry for pulling the source code
REGISTRY_SRC_TAG=v2.8.0

# go build param
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for golang cross-compilation parameters

@@ -147,6 +153,17 @@ DOCKERSAVE=$(DOCKERCMD) save
DOCKERCOMPOSECMD=$(shell which docker-compose)
DOCKERTAG=$(DOCKERCMD) tag

# according to the build platform, replace the relevant parameters.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If compiling the image of the arm architecture, replace the build image parameters arm suffix

GOARCH=arm64
TRIVY_DOWNLOAD_URL=https://github.com/aquasecurity/trivy/releases/download/$(TRIVYVERSION)/trivy_$(TRIVYVERSION:v%=%)_Linux-ARM64.tar.gz
TRIVY_ADAPTER_DOWNLOAD_URL=https://github.com/aquasecurity/harbor-scanner-trivy/releases/download/$(TRIVYADAPTERVERSION)/harbor-scanner-trivy_$(TRIVYADAPTERVERSION:v%=%)_Linux_arm64.tar.gz
DOCKERBUILD=$(DOCKERCMD) buildx build --platform linux/arm64 --progress plain --output=type=docker
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace docker build with dokcer buildx

@@ -371,27 +388,27 @@ check_environment:
compile_core: gen_apis
@echo "compiling binary for core (golang image)..."
@echo $(GOBUILDPATHINCONTAINER)
@$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATHINCONTAINER) -w $(GOBUILDPATH_CORE) $(GOBUILDIMAGE) $(GOIMAGEBUILD_CORE) -o $(GOBUILDPATHINCONTAINER)/$(GOBUILDMAKEPATH_CORE)/$(CORE_BINARYNAME)
@$(DOCKERCMD) run --rm --env GOOS=$(GOOS) --env GOARCH=$(GOARCH) -v $(BUILDPATH):$(GOBUILDPATHINCONTAINER) -w $(GOBUILDPATH_CORE) $(GOBUILDIMAGE) $(GOIMAGEBUILD_CORE) -o $(GOBUILDPATHINCONTAINER)/$(GOBUILDMAKEPATH_CORE)/$(CORE_BINARYNAME)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass golang cross-compilation parameters during compilation to support multi-architecture compilation

@@ -22,12 +22,17 @@ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/insta
sudo service postgresql stop || echo no postgresql need to be stopped
sleep 2

# support for multi-architecture compilation
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are building an arm image, the replacement tag should have a tag with an arm suffix

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant this be bundled tho?
image

@@ -8,7 +8,7 @@ docker run --env LDAP_ORGANISATION="Harbor." \
--env LDAP_TLS_VERIFY_CLIENT="never" \
-p 389:389 \
-p 636:636 \
--detach --name $NAME osixia/openldap:1.1.7
--detach --name $NAME osixia/openldap:1.5.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openldap version 1.5.0 is a multi-architecture mirror

@@ -7,8 +7,19 @@ ARG MOCKERY_VERSION
ENV XDG_CACHE_HOME /tmp
ENV GO111MODULE auto

RUN mkdir -p /tmp/mockery-${MOCKERY_VERSION} && \
RUN ARCH= && dpkgArch="$(uname -m)" \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mockery component supports building arm images

tools/spectral/Dockerfile Show resolved Hide resolved
tools/swagger/Dockerfile Show resolved Hide resolved
@AllForNothing AllForNothing added the release-note/enhancement Label to mark PR to be added under release notes as enhancement label Dec 12, 2022
@codecov
Copy link

codecov bot commented Dec 12, 2022

Codecov Report

Merging #17968 (028c28a) into main (da8dae3) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17968      +/-   ##
==========================================
+ Coverage   66.40%   66.42%   +0.01%     
==========================================
  Files        1012     1012              
  Lines      108670   108670              
  Branches     2674     2674              
==========================================
+ Hits        72167    72182      +15     
+ Misses      32540    32528      -12     
+ Partials     3963     3960       -3     
Flag Coverage Δ
unittests 66.42% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/controller/event/handler/auditlog/auditlog.go 14.28% <0.00%> (-42.86%) ⬇️
...g-retention-tasks/tag-retention-tasks.component.ts 75.00% <0.00%> (-9.38%) ⬇️
...dashboard/schedule-card/schedule-card.component.ts 43.28% <0.00%> (-2.99%) ⬇️
src/server/v2.0/handler/user.go 13.43% <0.00%> (+1.55%) ⬆️
...-job/gc-page/gc/gc-history/gc-history.component.ts 46.51% <0.00%> (+5.81%) ⬆️
...audit-log-purge/history/purge-history.component.ts 46.51% <0.00%> (+5.81%) ⬆️
...es/vulnerability/vulnerability-config.component.ts 62.96% <0.00%> (+8.88%) ⬆️
...d/worker-card/donut-chart/donut-chart.component.ts 60.00% <0.00%> (+11.42%) ⬆️

@Jeremy-boo Jeremy-boo force-pushed the feat/harbor_arm_build_make_to_main branch from cd0a600 to 70d8e5f Compare December 12, 2022 14:37
Signed-off-by: Jeremy-boo <bozhu@alauda.io>
@lengrongfu
Copy link
Contributor

@Jeremy-boo Hi, I want to know why the current pr has not been merged, and I hope I can help solve some problems.

@Jeremy-boo
Copy link
Author

@Jeremy-boo Hi, I want to know why the current pr has not been merged, and I hope I can help solve some problems.

Sorry, this PR has already been reviewed before. I was busy at the beginning of the year and didn’t have time to deal with the comments. I will send time to deal with the comments this weekend, and then re-initiate the review process. Thank you very much

@github-actions
Copy link

This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days.

@github-actions github-actions bot added the Stale label Apr 11, 2023
@odidev
Copy link

odidev commented Apr 11, 2023

@dioguerra @wy65701436
Could you please review this PR?

@github-actions github-actions bot removed the Stale label Apr 12, 2023
@wy65701436 wy65701436 changed the title feat: add harbor arm build parameters [WIP] feat: add harbor arm build parameters May 15, 2023
@jamezrin
Copy link

Any news regarding this PR?

@github-actions
Copy link

This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days.

@github-actions github-actions bot added the Stale label Sep 12, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 30 days with no activity. If this PR is still relevant, please re-open a new PR against main.

@github-actions github-actions bot closed this Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/enhancement Label to mark PR to be added under release notes as enhancement Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants