harbor
harbor copied to clipboard
Reduce image size
Comprehensive Summary of your change
Do following actions to reduce the size of the generated images.
- Change
COPY
command +chown
/chmod
command toCOPY
command +--chown
/--chmod
option. To prevent both files before/afterchown
/chmod
commands from being recorded on different layers. - Put all
tdnf
commands in a singleRUN
command and movetdnf clean all
command to the end. To prevent thetdnf
cache from being recorded on a layer, and thetdnf
database from being recorded on multiple layers. - Add
--link
option toCOPY
command. This does not contribute to image size reduction, but makes image building more efficient. - Move
chown /etc/pki/tls/certs
to theDockerfile.base
. This does not contribute to image size reduction, but is used in conjunction withCOPY --link
to make image building more efficient.
The target images and their sizes are as follows. (The sizes are the value when built locally)
- harbor-core : 185MB -> 118MB
- harbor-db : 285MB -> 263MB
- harbor-exporter : 108MB -> 79.1MB
- harbor-jobservice : 159MB -> 105MB
- harbor-registryctl : 160MB -> 104MB
- redis-photon : 179MB -> 170 MB
- standalone-db-migrator : 328MB -> 284MB
Note that harbor-log, harbor-portal, and nginx-photon have almost no effect, and prepare is not directly executed by the user, so they are not included.
Also, registry-photon and trivy-adapter-photon are not included, since PR #20622 and PR #20623 include equivalent action for these two, respectively.
Issue being fixed
Please indicate you've done the following:
- [x] Well Written Title and Summary of the PR
- [x] 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"
- [x] Accepted the DCO. Commits without the DCO will delay acceptance.
- [x] 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.