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(docker): Improve Dockerfile #125

Merged
merged 2 commits into from
May 15, 2023
Merged

feat(docker): Improve Dockerfile #125

merged 2 commits into from
May 15, 2023

Conversation

corrieriluca
Copy link
Member

Features

Use fixed versions in FROM statements

Fixes #84.

FROM docker.io/library/golang:1.19.9@sha256:9613596d7405705447f36440a59a3a2a1d22384c7568ae1838d0129964c5ba13 as builder

FROM docker.io/library/alpine:3.18.0@sha256:02bb6f428431fbc2809c5d1b41eab5a68350194fb508869a33cb1af4444c9b11

Note

The SHA256 digests are the ones of the multi-platform image's manifest, obtained with the two followings commands as of May 14th, 2023:

docker buildx imagetools inspect golang:1.19.9
docker buildx imagetools inspect alpine:3.18.0

This enables the Docker image to be built with these fixed versions on any platform supported by the referenced manifests.

Reduce Docker image size

Fixes #124.

By using alpine:3.18.0 instead of golang:alpine, the size decreases from ~390MB to ~96MB.

Adding the --no-cache option reduces the image only by ~1.5MB but is common practice.

Now the final image has a size of ~95MB.

Note

The size described are for the linux/arm64/v8 architecture, I did not tested on linux/amd64, but the gains should be similar.

@corrieriluca corrieriluca requested review from spoukke and Alan-pad May 14, 2023 14:22
@corrieriluca corrieriluca added the enhancement New feature or request label May 14, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #125 (f2156f5) into main (192ca72) will not change coverage.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##             main     #125   +/-   ##
=======================================
  Coverage   45.08%   45.08%           
=======================================
  Files          23       23           
  Lines        1546     1546           
=======================================
  Hits          697      697           
  Misses        822      822           
  Partials       27       27           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Alan-pad Alan-pad merged commit 2fe1ddc into main May 15, 2023
@corrieriluca corrieriluca deleted the feat/improve-dockerfile branch May 15, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce Docker image size Use fixed versions in the dockerfile
3 participants