docker spa

This commit is contained in:
Irwan Cahyono 2025-07-31 14:08:55 +07:00
parent df9fe7a112
commit 91b357049e
2 changed files with 8 additions and 14 deletions

View File

@ -3,14 +3,11 @@ FROM node:24-alpine AS builder
WORKDIR /app WORKDIR /app
# Install dependencies
COPY package*.json ./ COPY package*.json ./
RUN npm install --legacy-peer-deps RUN npm install --legacy-peer-deps
# Salin semua source code
COPY . . COPY . .
# Build project Nuxt 3
RUN npm run build RUN npm run build
# Tahap production # Tahap production
@ -18,18 +15,10 @@ FROM node:24-alpine AS runner
WORKDIR /app WORKDIR /app
# NODE_ENV untuk optimasi dependency RUN npm install -g serve
ENV NODE_ENV=production
# Salin hanya file penting untuk runtime COPY --from=builder /app/.output/public ./public
COPY --from=builder /app/.output ./.output
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Pastikan ini file ada
RUN test -f .output/server/index.mjs
EXPOSE 3000 EXPOSE 3000
# Jalankan Nuxt 3 SSR CMD ["serve", "-s", "public", "-l", "3000"]
CMD ["node", ".output/server/index.mjs"]

View File

@ -9,3 +9,8 @@ services:
environment: environment:
- NODE_ENV=production - NODE_ENV=production
restart: unless-stopped restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"