diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 322cca4..7672b3c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,15 +1,31 @@ -FROM node:20-alpine +# --- Stage 1: Build --- +FROM node:20-alpine AS builder -RUN mkdir -p /usr/src/nuxt-app WORKDIR /usr/src/nuxt-app -COPY . . -RUN npm i +# Nur Files kopieren, die für die Installation nötig sind (besseres Caching) +COPY package*.json ./ +RUN npm install + +# Restlichen Code kopieren und bauen +COPY . . RUN npm run build +# --- Stage 2: Runtime --- +FROM node:20-alpine AS runner + +WORKDIR /usr/src/nuxt-app + +# Von der Build-Stage NUR den fertigen .output Ordner kopieren +COPY --from=builder /usr/src/nuxt-app/.output ./.output + +# Optional: Falls du statische Dateien aus public brauchst, +# sind diese normalerweise bereits in .output/public enthalten. + ENV NUXT_HOST=0.0.0.0 ENV NUXT_PORT=3000 +ENV NODE_ENV=production EXPOSE 3000 -ENTRYPOINT ["node", ".output/server/index.mjs"] +ENTRYPOINT ["node", ".output/server/index.mjs"] \ No newline at end of file