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

chore: [VIO-3019] Update the Dockerfiles #119

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

AdamIsrael
Copy link
Contributor

@AdamIsrael AdamIsrael commented Jul 7, 2023

Update the Dockerfiles to use the debian:stable-slim as the builder, and scratch for the final (production) image.

Final image size reduced from 14.5MB to 14MB.

Update the `Dockerfile`s to use the `debian:stable-slim` as the builder,
and `scratch` for the final (production) image.
Copy link
Contributor

@GuessWhoSamFoo GuessWhoSamFoo left a comment

Choose a reason for hiding this comment

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

I think it is time to move away from COPY synse-emulator-plugin ./plugin. We get away with this because goreleaser ends up pushing the docker image. However it won't make sense for a user if they have to download the whole toolchain on host to compile the binary when we're using a builder for Docker.

Build the go binary statically linked so that it works in the `scratch`
image.

Runs as the `vaporio` user, instead of root.
@AdamIsrael
Copy link
Contributor Author

I think it is time to move away from COPY synse-emulator-plugin ./plugin. We get away with this because goreleaser ends up pushing the docker image. However it won't make sense for a user if they have to download the whole toolchain on host to compile the binary when we're using a builder for Docker.

This updated PR does two things: builds the go binary statically (the default dynamically linked binary doesn't run inside the scratch image.

Runs the binary as a specific user. That's a new pattern we're adopting across Dockerfiles.

@AdamIsrael
Copy link
Contributor Author

Looks like it's failing with goreleaser. I see now that gorelease is building the binary and then trying to build the Dockerfile, and I'm reading through how we should be structuring the Dockerfile to work with goreleaser.

I'll migrate my Dockerfile changes to dev.Dockerfile so the build is still done through Docker for local/test builds, and refactor to work with goreleaser.

In `dev.Dockerfile`, build the binary inside the Dockerfile build.
In `Dockerfile`, follow the goreleaser pattern
In `Makefile`, the `docker` target builds the image via gobuilder
In `README.md`, add a "build" section to link to the goreleaser install
page and document how to build the production image locally.
@AdamIsrael
Copy link
Contributor Author

I refactored the Dockerfile(s) a bit.

First, I moved the changes I'd made to build the go binary in the docker build to dev.Dockerfile.
Second, I refactored Dockerfile according to the goreleaser docker-build suggestions.
Lastly, I added a build section to the README to document the use of goreleaser to build a production image locally.

@AdamIsrael
Copy link
Contributor Author

One last note: it looks like the release workflow tried to run against this PR. It failed, because the versions are the same, but it should probably only run on a new tagged release.

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