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

docker preset #54

Open
pi0 opened this issue Apr 8, 2022 · 3 comments
Open

docker preset #54

pi0 opened this issue Apr 8, 2022 · 3 comments

Comments

@pi0
Copy link
Member

pi0 commented Apr 8, 2022

Built with node and a minimal generated docker image:

  • Default: Only generate Dockerfile
  • Build option provided: Try to also build an image using the local docker client CLI (alternative would be a JS client but is too much hassle)
  • Compose option provided: Generate basic docker-compose
  • Registry option provided: Also push to the register

Note: It might improve heroku preset as well (#49)

@pi0 pi0 added enhancement New feature or request preset proposal labels Apr 8, 2022
@pi0 pi0 self-assigned this Apr 8, 2022
This was referenced Apr 8, 2022
@pi0
Copy link
Member Author

pi0 commented May 31, 2022

Relevant comment nuxt/framework#5077 (comment) from @sarim, we might use or embed tini as init process to avoid using node with PID 0. (I need to investigate more)

@mishushakov
Copy link

hey @pi0,
does this imply that the application will have to be built outside of Docker first?
so the Dockerfile generated is only for deployment, correct?

in this case, i don't see it as being very useful
the goal of Docker is reproducible builds and having to build the application outside of Docker goes against that

technically this means you'll have to setup a CI action to build the application and then another CI action to build the Dockerfile
that won't work in many corporate CI-environments

in my experience things already work as is and currently i don't see a benefit of having a Docker preset
a Dockerfile template, such as the one i provided in my PR covers 90% of use-cases already

one argument was that people use different package managers
the solution would be just offering Dockerfile templates for each package manager

doesn't need to be more complicated that that!
would be happy to hear your feedback

@pi0 pi0 added the documentation Improvements or additions to documentation label Feb 16, 2023
@pi0 pi0 added p2-nice-to-have and removed documentation Improvements or additions to documentation enhancement New feature or request labels May 16, 2024
@luc122c
Copy link
Contributor

luc122c commented Oct 22, 2024

I have been using this as my dockerfile for deploying Nuxt apps:

ARG NODE_VERSION=20
FROM node:${NODE_VERSION} as build
WORKDIR /app

# Install dependencies
RUN corepack enable
COPY --link package.json pnpm-lock.yaml ./
RUN pnpm i --frozen-lockfile

# Copy source files
COPY --link . .

# Build application
ENV NITRO_PRESET=node-server
RUN pnpm run build

# https://github.com/GoogleContainerTools/distroless/blob/main/nodejs/README.md
FROM gcr.io/distroless/nodejs${NODE_VERSION} as runtime
WORKDIR /app

ARG PORT=3000
ENV NITRO_HOST=0.0.0.0
ENV NITRO_PORT=${PORT}
EXPOSE ${PORT}

COPY --from=build /app /app

CMD [ ".output/server/index.mjs" ]

Which can be built with a command like this:
docker build --build-arg NODE_VERSION=22 -t my/nuxt-app .

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