I have a Nuxt / Vue.js based app (example code here), where I already used Cloud Native Buildpacks to build a container for the Server Side Rendering mode. I'm in the process of migrating to Nuxt 3.x / Vue.js 3.x and updated my Paketo build to a newer builder image accordingly:
pack build ghcr.io/jonashackt/microservice-ui-nuxt-js:latest \
--builder paketobuildpacks/builder-jammy-base \
--path .
Sadly when I try to run the container after a successful build using the following command (for how to generally build and run a Nuxt-based container with Cloud Native Buildpacks see this answer):
docker run --rm -i --tty --env "HOST=0.0.0.0" -p 3000:3000 ghcr.io/jonashackt/microservice-ui-nuxt-js
I get the following error:
ERROR: failed to launch: determine start command: when there is no default process a command is required
How can I build a container that runs out-of-the-box or - if thats not possible - override the entrypoint or something?
As taken from this post running Nuxt 3 in Docker takes the following ENTRYPOINT
configuration: ENTRYPOINT ["node", ".output/server/index.mjs"]
. Thus it should be easy to override this at the docker run
command. But luckily I stumbled upon the depts of the Paketo node.js docs, where it is described how to specify a custom entrypoint right at the Paketo build time!
We need to leverage the --env
parameter BP_LAUNCHPOINT
here. My working pack build
command then looks like this:
pack build ghcr.io/jonashackt/microservice-ui-nuxt-js:latest \
--builder paketobuildpacks/builder-jammy-base \
--env BP_LAUNCHPOINT=".output/server/index.mjs" \
--path .
With that solution the correct entrypoint is baked into the image and we don't need to bother with it at runtime. Thus the docker run
command stays the same:
docker run --rm -i --tty --env "HOST=0.0.0.0" -p 3000:3000 ghcr.io/jonashackt/microservice-ui-nuxt-js