Skip to content

Commit

Permalink
Working Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sentanos committed Oct 15, 2024
1 parent f030364 commit a760c26
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
43 changes: 36 additions & 7 deletions dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
FROM node:21 as build
# Derived from
# https://github.com/vercel/next.js/blob/4b9ef1eb23f9d247321c9368d08c2398b6ec8169/examples/with-docker/Dockerfile
FROM node:21-alpine AS base

FROM base AS deps
WORKDIR /app

ENV NODE_ENV production

COPY package*.json /app/
RUN npm ci --legacy-peer-deps

COPY . ./
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npm run build

FROM nginx
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3001

WORKDIR /usr/share/nginx/html
ENV PORT=3001

COPY --from=build /app/out/ ./
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
1 change: 1 addition & 0 deletions dashboard/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ module.exports = {
},
];
},
output: 'standalone'
};

0 comments on commit a760c26

Please sign in to comment.