Having 404 on resources when using standalone
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
I am using standalone for my nextjs project, but I am getting 404 on every resource as shown in the photo, this is only when using docker and
My dockerfile:
node server.js, not sure why this is happening. If I use npm run start (or whatever package manager) it will work correctly and even if I use node server.js outside docker it works.My dockerfile:
FROM node:18 AS base
# Install dependencies only when needed
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
#RUN apk add --no-cache libc6-compat
#RUN apk add --no-cache curl
#RUN apk add --no-cache --upgrade bash
WORKDIR /app
# Install dependencies based on the preferred package manager
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
COPY . .
RUN bun install
# Rebuild the source code only when needed
#COPY --from=deps /app/node_modules ./node_modules
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
RUN bun run build
#EXPOSE 3000
#CMD ["bun", "run", "start"]
#Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
COPY --from=builder /app/apps/web/next.config.js ./
COPY --from=builder /app/apps/web/public ./public
COPY --from=builder /app/apps/web/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"
CMD ["node", "apps/web/server.js"]