diff --git a/Dockerfile b/Dockerfile index 0eff423..697a927 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,32 @@ # 1. Install dependencies -FROM node:20-alpine AS deps +FROM node:alpine AS deps +RUN apk add --no-cache libc6-compat WORKDIR /app COPY package*.json ./ RUN npm ci # 2. Build the app -FROM node:20-alpine AS builder +FROM node:alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -# Vi mappar in miljövariabler under build om det behövs ENV NEXT_TELEMETRY_DISABLED 1 RUN npm run build -# 3. Production image -FROM node:20-alpine AS runner +# 3. Production image (Slimmad!) +FROM node:alpine AS runner WORKDIR /app ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 -# Skapa data-mappen för Micro-CMS RUN mkdir -p data COPY --from=builder /app/public ./public -COPY --from=builder /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static EXPOSE 3000 -CMD ["npm", "start"] \ No newline at end of file +ENV PORT 3000 +ENV HOSTNAME "0.0.0.0" + +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index e9ffa30..f701d94 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,9 @@ +// next.config.ts + import type { NextConfig } from "next"; const nextConfig: NextConfig = { + output: 'standalone', /* config options here */ };