Skip to content

make image (much) smaller#34

Open
lmaotrigine wants to merge 1 commit into5HT2B:masterfrom
lmaotrigine:smol-image
Open

make image (much) smaller#34
lmaotrigine wants to merge 1 commit into5HT2B:masterfrom
lmaotrigine:smol-image

Conversation

@lmaotrigine
Copy link
Member

This commit just makes use of docker multi-stage builds. Since Go links everything statically, and we only need libc at runtime, and not the plethora of tools in the Go base image, we run from a distroless image with just the binary and the static assets.

This brings down the image size by ~62.5% (1.13GiB --> 30.2MiB)

This commit just makes use of docker multi-stage builds. Since Go
links *everything* statically, and we only need `libc` at runtime,
and not the plethora of tools in the Go base image, we run from a
distroless image with just the binary and the static assets.
go get -u github.com/valyala/quicktemplate
go get -u golang.org/x/text/language
go get -u golang.org/x/text/message
go get -u ./...
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, is there documentation on what this actually does?

I assume it just pulls everything needed as specified in the go.mod, but I'd prefer to be certain.

Copy link
Member Author

@lmaotrigine lmaotrigine Jan 21, 2026

Choose a reason for hiding this comment

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

from https://go.dev/ref/mod#go-get

Upgrade modules that provide packages imported by packages in the main module.

it's just easier to do this than keep the list up to date here as well.

Copy link
Member

Choose a reason for hiding this comment

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

Ohh okay. I will resolve this specific change once I test locally to see if it does do go.mod / go.sum upgrades as expected.

ADD . /heartbeat
WORKDIR /heartbeat
RUN mkdir -p /heartbeat/config
COPY . .
Copy link
Member

Choose a reason for hiding this comment

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

Does this still create the heartbeat folder inside of /data as needed? Including the empty folders?

Mainly, we need the contents of /heartbeat/config inside of /heartbeat so when it is mounted, the config files reside inside of /data/heartbeat

Copy link
Member Author

Choose a reason for hiding this comment

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

the data path is deliberately not created because it's intended to be a volume mount. at the time of writing, i did not know that the VOLUME instruction exists. making the config directory avoids permission issues when mounting files alone. it's not the best solution, admittedly, but hardening is probably for another PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay. I'm also unfamiliar with VOLUME, we do need to make changes to the internal server in order for it to work with the configuration that you have here? As far as I can tell?

Please let me know if I'm mistaken or if there's something I'm missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do remember testing this at the time, and it didn't seem to require any further modification. I'll test this again as soon as possible, but I don't think I'll have time until February. I see that there is a merge conflict so I might have failed to notice changes in the meantime.

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.

2 participants