-
Notifications
You must be signed in to change notification settings - Fork 263
[gen] Implement gen prod dockerfile #2017
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ type Opts struct { | |
} | ||
|
||
type GenerateOpts struct { | ||
ForType string | ||
Force bool | ||
RootUser bool | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM jetpackio/devbox:latest | ||
|
||
WORKDIR /code | ||
USER root:root | ||
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code | ||
USER ${DEVBOX_USER}:${DEVBOX_USER} | ||
|
||
{{- /* | ||
Ideally, we first copy over devbox.json and devbox.lock and run `devbox install` | ||
to create a cache layer for the dependencies. This is complicated because | ||
devbox.json may include local dependencies (flakes and plugins). We could try | ||
to copy those in (the way the dev Dockerfile does) but that's brittle because | ||
those dependencies may also pull in other local dependencies and so on. Another | ||
sulution would be to add a new flag `devbox install --skip-errors` that would | ||
just try to install what it can, and ignore the rest. | ||
|
||
A hack to make this simpler is to install from the lockfile instead of the json. | ||
*/}} | ||
|
||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . | ||
|
||
RUN devbox install | ||
|
||
RUN {{ .DevboxRunInstall }} | ||
|
||
RUN {{ .DevboxRunBuild }} | ||
|
||
CMD [{{ .Cmd }}] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope we can optimize this image further, especially it is supposedly for prod. Right now it builds for a long time and the image ends up super big. Something like:
Although I don't know how much those steps could help. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LucilleH for sure! I think some of those might be doable without devbox changes (but not all).
I can try this, but in theory the nix store should be pretty clean no? We haven't installed anything we don't need.
This can help a bit but not without changes. Ideally, we do shellenv and then call the raw start command (without using
Where
This is the biggest win. But see my comment about local dependencies. I think there's 2 huge optimizations here:
(1) is easy, but requires a new flag/command so we can ignore errors of missing local dependencies. My preference is to merge this and optimize in follow up. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an issue with using
devbox install
command in dockerfile. IIRC it didn't activate the python plugin so the subsequent python commands were not running in a virtual environment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the issue I'm talking about:
#1122
can you test the steps in the issue to make sure we don't regress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by that issue. I understand that
install
doesn't run init hooks, but I would assume the line belowRUN devbox shellenv --init-hook >> ~/.profile
Would do the initialization.
Furthermore, actually activating the virtual environment is a manual process so neither install/run would do it.
Do you know why shellenv is not working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, since the prod dockerfile always ends in
devbox run start
it will always run the init hook which creates the virtenv. To activate it, the user would need to add that to their start command. Maybe we can add an env variable that automatically activates it.