diff --git a/Dockerfile b/Dockerfile index 71caa22..0585a3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,33 @@ -FROM node:18-alpine +# Build stage +FROM node:18-alpine AS builder WORKDIR /app -COPY package.json package-lock.json ./ +COPY package*.json ./ RUN npm install COPY . . +RUN npm run build + +# Production stage +FROM node:18-alpine AS runner +WORKDIR /app + +ENV NODE_ENV production + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# Copy necessary files +COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +USER nextjs + EXPOSE 3000 -CMD ["npm", "run", "dev"] +ENV PORT 3000 +ENV HOSTNAME "0.0.0.0" + +CMD ["node", "server.js"] # Hinweis: # Bei Next.js übernimmt Node.js den Webserver für die Auslieferung der Seiten. diff --git a/next.config.js b/next.config.js index 69287b6..2d1cc4d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ module.exports = { reactStrictMode: true, + output: 'standalone', images: { domains: ['images.unsplash.com', 'localhost'], },