Skip to content

Provide a Dockerfile #62

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

Open
juliangorge opened this issue Dec 8, 2024 · 2 comments
Open

Provide a Dockerfile #62

juliangorge opened this issue Dec 8, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@juliangorge
Copy link

Hi Kiranism,

Thank you for this amazing repo! I’m using it in a couple of projects, and it’s been incredibly helpful.

Would you consider adding a Dockerfile? I tried using the official Next.js Dockerfile, but deployment takes an extremely long time (around 30 minutes on a VPS).

Best regards!

@IgorRSGraziano
Copy link

Unfortunately NextJS can be a bit annoying for Docker.
To reduce the build time problem, you can build on your machine, or on a server (like Github Actions) and upload to a docker registry.

If you want a ready-made Dockerfile, I use this one:

!! (you will have problems with it if you are using NEXT_PUBLIC variables)

FROM node:21-alpine AS base

RUN apk add --no-cache libc6-compat

FROM base AS dev

WORKDIR /usr/app

COPY package*.json ./

RUN npm ci

FROM base AS build

WORKDIR /usr/app

ENV NODE_ENV="production"

COPY --from=dev /usr/app/package*.json ./
COPY --from=dev /usr/app/node_modules ./node_modules

COPY . .

RUN rm -rf *.env

RUN npm run build

RUN npm prune --production

FROM base AS prod

WORKDIR /usr/app

COPY --from=build /usr/app/.next ./.next
COPY --from=build /usr/app/node_modules ./node_modules
COPY --from=build /usr/app/package*.json ./

CMD ["npm", "run", "start"]


@Kiranism Kiranism added the help wanted Extra attention is needed label Dec 12, 2024
@wan-kong
Copy link

wan-kong commented Jan 8, 2025

an example from next.js
https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
also remeber update the output: standalone in next.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants