Start of container with generated Dockerfile is super slow
What problem are you trying to solve?
The Dockerfile generated by the command devbox generate dockerfile has a super slow startup.
The first invocation of devbox shell seems to do some initialization, even though all packages have already been installed. After the initial invocation it is really fast. But before that in my example it too >1 minute on the first run.
I use my devbox built docker container to debug stuff on a Kubernetes cluster and having 1 minute to wait for the container to initialize is not practical.
FROM jetpackio/devbox:latest
# Installing your devbox project
WORKDIR /code
USER root:root
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
USER ${DEVBOX_USER}:${DEVBOX_USER}
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
RUN devbox run -- echo "Installed Packages."
CMD ["devbox", "shell"]
What solution would you like?
Either in documentation or as part of the generate command: Option to pre-initialize the shell.
I tried with devbox shell as part of the build process. But this seems strange as probably eveyone wants to have this pree-initialized?
https://github.com/iptizer/swiss/blob/master/Dockerfile#L12
Alternatives you've considered
No response
Like you point out, it seems like the installation step could be moved into the image build:
FROM jetpackio/devbox:latest
# Installing your devbox project
WORKDIR /code
USER root:root
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
USER ${DEVBOX_USER}:${DEVBOX_USER}
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
- RUN devbox run -- echo "Installed Packages."
+ RUN devbox install
CMD ["devbox", "shell"]
Additionally I think RUN devbox run -- echo "Installed Packages." is misleading because it doesn't actually appear to install packages.