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

fix: Exclude .deb files from release Docker image #5068

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

dwahler
Copy link
Contributor

@dwahler dwahler commented Apr 5, 2022

Currently, the codercom/code-server Docker image includes a copy of the release's .deb package files, even though they're only used in an intermediate layer. What's more, it includes packages from every architecture, not just the one being released.

This patch fixes this by updating the Dockerfile to use a multi-stage build. First, the packages are copied from the local build context into a temporary directory in a "scratch" build stage. Then, this directory is mounted into the main build, so that the appropriate .deb file can be installed without ever being actually stored in the image.

In my testing (with the 4.2.0 packages for linux-amd64) this reduces the total compressed and uncompressed size by a fairly substantial amount:

Before After Change
compressed 637 MB 268 MB -58%
uncompressed 1094 MB 724 MB -34%

Partially fixes #4112

@dwahler dwahler requested a review from a team April 5, 2022 23:05
@dwahler
Copy link
Contributor Author

dwahler commented Apr 6, 2022

I guess the "semantic pull request" check is failing because it wants a prefix on the PR title, but I'm not sure what would be most appropriate. It's not really a "feature", so maybe "perf"?

@code-asher
Copy link
Member

Good question. perf seems good to me although we do not have that as an option so we would need to add it.

types:
# A build of any kind.
- build
# A user-facing change that corrects a defect in code-server.
- fix
# Any code task that is ignored for changelog purposes. Examples include
# devbin scripts and internal-only configurations.
- chore
# Any work performed on CI.
- ci
# Work that directly implements or supports the implementation of a feature.
- feat
# A refactor changes code structure without any behavioral change.
- refactor
# A git revert for any style of commit.
- revert
# Adding tests of any kind. Should be separate from feature or fix
# implementations. For example, if a commit adds a fix + test, it's a fix
# commit. If a commit is simply bumping coverage, it's a test commit.
- test
# A new release.
- release

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Those are some excellent savings. The multi-stage build is clever! Thanks for the improvement!

@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #5068 (63d0128) into main (5bc26e9) will not change coverage.
The diff coverage is n/a.

❗ Current head 63d0128 differs from pull request most recent head 163938d. Consider uploading reports for the commit 163938d to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5068   +/-   ##
=======================================
  Coverage   71.30%   71.30%           
=======================================
  Files          30       30           
  Lines        1683     1683           
  Branches      373      373           
=======================================
  Hits         1200     1200           
  Misses        413      413           
  Partials       70       70           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bc26e9...163938d. Read the comment docs.

@jsjoeio jsjoeio added enhancement Some improvement that isn't a feature chore Related to maintenance or clean up labels Apr 6, 2022
@jsjoeio jsjoeio added this to the April 2022 milestone Apr 6, 2022
@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 6, 2022

Echoing Asher, those are some huge improvements. Thank you so much for doing this!

@jsjoeio jsjoeio changed the title Exclude .deb files from release Docker image fix: Exclude .deb files from release Docker image Apr 6, 2022
@jsjoeio jsjoeio merged commit 38e57a3 into coder:main Apr 6, 2022
@jsjoeio jsjoeio modified the milestones: April 2022, 4.3.0 Apr 13, 2022
TinLe pushed a commit to TinLe/code-server that referenced this pull request Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Related to maintenance or clean up enhancement Some improvement that isn't a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smaller docker image for production?
3 participants