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

Use a Multi stage Dockerfile to eliminate the need for our own base image #3518

Closed
godber opened this issue Jan 9, 2024 · 1 comment
Closed

Comments

@godber
Copy link
Member

godber commented Jan 9, 2024

I think we should at least try to rejigger our Teraslice Dockerfile to try and eliminate the need for maintaining our own base image. I think the approach would be to use a Multistage Dockerfile (https://docs.docker.com/build/building/multi-stage/) whose first stage creates a temporary "dev image" (not pushed anywhere) that has all the node-gyp C dependencies and builds Teraslice. Then the second stage will build a smaller final image from the output of the dev image.

Roughly speaking:

I think we can still parameterize the Node version the same way we are now. Our main goal here is to isolate the changes as much as possible in the Dockerfile and making sure what we build passes e2e tests.

Ref:

When considering naming schemes for our Docker images in the issue below, I thought its probably worth trying out:

https://github.com/terascope/debian-base/issues/1#issuecomment-1883904854

@godber godber changed the title Use a Multie stage Dockerfile to eliminate the need for our own base image Use a Multi stage Dockerfile to eliminate the need for our own base image Jan 9, 2024
godber added a commit that referenced this issue Jan 11, 2024
Rewrite Teraslice Dockerfile to be multistage and use node image

This PR makes the following changes:

- Rewrite docker file:
  - Discontinue use of `base-docker-image`
  - Create a multi-stage build:
    - base stage:
      - build image from `debian-bookworm`
- combine functionality from the `base-docker-image` with the yarn build
step to create `/app` directory
    - second stage:
      - build image from `debian-bookworm-slim`
      - copy `/app` artifact from base stage, minimizing dependencies
- Copy the following scripts from `base-docker-image` repo to
`teraslice/scripts`:
  - `docker-pkg-fix.sh` (this doesn't seem to be used anywhere)
  - `wait-for-it.sh`

Ultimately the goal is to not have to manage our own base image.

ref: #3518

---------

Co-authored-by: Austin Godber <godber@terascope.io>
@godber
Copy link
Member Author

godber commented Feb 7, 2024

We attempted to roll out this change in the PR above in release:

https://github.com/terascope/teraslice/releases/tag/v0.91.0

But the resulting image showed significantly higher memory usage in large scale Kafka jobs so we rolled it back in this release:

https://github.com/terascope/teraslice/releases/tag/v0.92.0

For now this effort is on hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants