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

Simplify container image build #4962

Merged
merged 25 commits into from
Dec 15, 2023
Merged

Simplify container image build #4962

merged 25 commits into from
Dec 15, 2023

Conversation

ferrarimarco
Copy link
Collaborator

@ferrarimarco ferrarimarco commented Dec 9, 2023

Proposed Changes

  1. Define GLIBC_VERSION once as a global argument in Dockerfile to reduce duplication.
  2. Update the slim image to python:3.12.1-alpine3.19. For some reason, dependabot was failing with a 403 when analyzing this dependency.
  3. Install a specific hadolint version instead of latest to make the build more reproducible.
  4. Remove the base_image build step entirely. This stage was largely redundant because we copied everything we installed to slim anyway. This saves up some build time, and makes the Dockerfile simpler.
  5. Move static labels near the top of the Dockerfile.
  6. Move dynamic labels near the bottom of the Dockerfile to avoid invalidating the cache when they change.
  7. Move build arguments about linter versions to install where they are needed.
  8. Install bash first so that we can enable additional error checks right away.
  9. Move the longest Dockerfile build instructions earlier so we can better use the build cache.
  10. Move the installation of OS packages from scripts to Dockerfile when a package is needed by more than one linter.
  11. Move terrascan and chktexrc initialization from install-ktlint.sh to Dockerfile because they don't have anything to do with ktlint.
  12. Don't install glibc-compat multiple times in different script, and consolidate the logic to do this in a install-glibc.sh script.
  13. Fail on errors in subshells when installing dependencies using shell scripts (install-xxxxx.sh).
  14. Use phive.xml to install dependencies instead of listing them when invoking phive.
  15. Update phive.xml to install the same dependencies that we were installing explicitly from the command line. Note that phive.xml was already in /dependencies, but unused and outdated.
  16. Install Composer using Phive instead of using an ad-hoc script.
  17. Initialize TFLint plugins when building the Dockerfile so have the default ones in the image already.
  18. Add missing OS package installation tests.
  19. Add missing linter commands tests: gitleaks, prettier, renovate-config-validator, textlint, ts-standard.
  20. Add missing PyPi packages tests. We weren't testing any.
  21. Add missing NPM packages tests.
  22. Add missing maintainers from the build failure issues assignee template.
  23. Update CODEOWNERS according to the list of current maintainers.

Readiness Checklist

Author/Contributor

  • I included all the needed documentation for this change.
  • I provided the necessary tests.

Reviewing Maintainer

  • Label as breaking if this is a large, fundamental change.
  • Label as either: automation, bug, documentation, enhancement, infrastructure.

BEGIN_COMMIT_OVERRIDE
build: simplify container image build
END_COMMIT_OVERRIDE

@ferrarimarco ferrarimarco added the enhancement New feature or request label Dec 9, 2023
@ferrarimarco ferrarimarco self-assigned this Dec 9, 2023
@ferrarimarco ferrarimarco added infrastructure related to project structure and maintenance O: backlog 🤖 Backlog, stale ignores this label and removed enhancement New feature or request labels Dec 14, 2023
@ferrarimarco ferrarimarco marked this pull request as ready for review December 14, 2023 11:03
@ferrarimarco
Copy link
Collaborator Author

@zkoppert sorry if this turned to be quite big, but I kept finding new issues while fixing others :)

zkoppert
zkoppert previously approved these changes Dec 14, 2023
@ferrarimarco
Copy link
Collaborator Author

@zkoppert thanks for your review! I fixed a few conflicts, so no major changes since you reviewed. Going ahead with this one :)

@ferrarimarco ferrarimarco merged commit 22b8624 into main Dec 15, 2023
4 checks passed
@ferrarimarco ferrarimarco deleted the simplify-build branch December 15, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure related to project structure and maintenance O: backlog 🤖 Backlog, stale ignores this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants