Code Monkey home page Code Monkey logo

Comments (6)

tpdewolf avatar tpdewolf commented on June 22, 2024

I have the same issue
Next 14.2.3

.next folder in docker only includes these files and folders

cache
prerender-manifest.js
package.json
routes-manifest.json

from next.js.

devhik0 avatar devhik0 commented on June 22, 2024

I can't see what it includes cuz it's crashing due to that build error above.

from next.js.

tpdewolf avatar tpdewolf commented on June 22, 2024

@devhik0 You can ssh into the image by running docker run --rm -it myimage:latest sh (replace myimage:latest with your tag)

I do notice that it does work when I build the image in Github actions on ubuntu latest. When i'm building it on Mac m1 with --platform=linux/amd64 it doesnt create all files in .next

from next.js.

devhik0 avatar devhik0 commented on June 22, 2024

@tpdewolf Yes, but it's giving same error when I run container and stopping. Weird one, same app is running in GitHub actions machine on Ubuntu, but crashing on Windows. I tried building locally via Dockerfile, but when I run it crashed again cuz of same error.

from next.js.

Hulow avatar Hulow commented on June 22, 2024

hey,
almost the same for me:

  • I use Next.js 14.2.3.
  • The docker image run correctly on my local env but it gets stuck when i run the image on a ubuntu server.
  • I build my image FROM node:20-slim

from next.js.

devhik0 avatar devhik0 commented on June 22, 2024

So, update: Check your Dockerfile and other files to make sure its copying all files and have right permissions.
Here i ll share what i changed and how it fixed everything.

# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1

# RUN bun run test #todo: add here after adding tests
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
WORKDIR /app

# Set correct permissions for nextjs user and don't run as root
RUN adduser crm
RUN chown crm:bun .
USER crm

COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease --chown=crm:bun /app/.next ./.next
COPY --from=prerelease /app/node_modules ./node_modules
COPY --from=prerelease /app/package.json ./package.json
COPY --from=prerelease /app/public ./public
CMD ["bun", "run", "build"]
# run the app
EXPOSE 3000/tcp
CMD ["bun", "start" ]

If needs use it as reference

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.