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

feat: Add new go build tag no_openziti to reduce build size #795

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

judehung
Copy link
Member

@judehung judehung commented Nov 8, 2024

closes #789

The usage of OpenZiti packages to support zero trust feature significantly increases the build size. For example, core-metadata increases from 14MB to 21MB, core-command increases from 9.8MB to 17MB, device-virtual increases from 18MB to 31MB, and app-service-configurable increases from 22Mb to 34MB. As many edge user scenarios require to deploy EdgeX services on resource-constrained devices without security, allowing that the services can be built without OpenZiti packages and ZeroTrust features can be helpful to user cases which don't need zero trust feature.

This commit refactors the codes importing openziti packages with //go:build !no_openziti directive and creates para codes that don't use openziti packages with //go:build no_openziti directive, so users can simply build services by specifying no_openziti tag to build out services without openziti zero trust feature.

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-bootstrap/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

To test the new no_openziti build tag, please clone my forked edgex-go repository and checkout issue-789 branch:

git clone git@github.com:judehung/edgex-go.git
cd edgex-go
git checkout issue-789

The issue-789 branch has updated go.mod to replace go-mod-bootstrap with github.com/judehung/go-mod-bootstrap/v4 v4.0.0-20241109084700-c362e7cd73ed, which contains the changes of this PR:

replace github.com/edgexfoundry/go-mod-bootstrap/v4 => github.com/judehung/go-mod-bootstrap/v4 v4.0.0-20241109084700-c362e7cd73ed 

The issue-789 branch also updates Makefile to include a new target build-noziti, and you can build the edgex-go services without openziti packages with following make command:

go mod tidy
make build-noziti

This will build out core services and you can observe their binary executable size shrinks back to the same level as v3.1.

New Dependency Instructions (If applicable)

N/A

@judehung judehung force-pushed the issue-789 branch 2 times, most recently from 6e8f540 to 02f877d Compare November 8, 2024 14:44
closes edgexfoundry#789

The usage of OpenZiti packages to support zero trust feature significantly increases
the build size. For example, core-metadata increases from 14MB to 21MB, core-command
increases from 9.8MB to 17MB, device-virtual increases from 18MB to 31MB, and
app-service-configurable increases from 22Mb to 34MB. As many edge user scenarios
require to deploy EdgeX services on resource-constrained devices without security,
allowing that the services can be built without OpenZiti packages and ZeroTrust
features can be helpful to user cases which don't need zero trust feature.

This commit refactors the codes importing openziti packages with //go:build !no_openziti
directive and creates para codes that don't use openziti packages with
//go:build no_openziti directive, so users can simply build services by specifying
no_openziti tag.

Also remove vestigal zc variables and ZitiContext struct per discussion
with https://github.com/dovholuknf in
edgexfoundry#659 (comment)

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/app-functions-sdk-go that referenced this pull request Nov 9, 2024
realetd to edgexfoundry/go-mod-bootstrap#795

As go-mod-bootstrap is updated with new build tag no_openziti with some
code refactor, the app-functions-sdk-go also needs to be updated per the
refactor.

Signed-off-by: Jude Hung <jude@iotechsys.com>
@judehung judehung marked this pull request as ready for review November 11, 2024 03:03
@cloudxxx8
Copy link
Member

@dovholuknf please see if you have any opinoin from Jude's refactoring. OpenZiti will still be built in EdgeX by default.

judehung added a commit to judehung/edgex-go that referenced this pull request Nov 11, 2024
related to edgexfoundry/go-mod-bootstrap#795

To allow to build services without openziti, add new targte build-noziti
into Makefile

Signed-off-by: Jude Hung <jude@iotechsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add go build tags no_openziti to reduce image/executable build size
2 participants