diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b99280e..f75b7d2 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,35 +1,33 @@ # Gunakan base image yang lebih ringan FROM node:18-alpine AS builder -# Set working directory WORKDIR /app -# Copy package.json dan package-lock.json +# Copy package.json dan package-lock.json (kalau ada) COPY package*.json ./ -# Install dependencies (termasuk dev) di stage build -RUN npm ci +# Install dependencies (termasuk dev) +# Ganti npm ci -> npm install biar gak error kalau belum ada lock file +RUN npm install -# Copy semua source code +# Copy seluruh source code COPY . . -# Build React app (kalau ini frontend) +# Build React app RUN npm run build - # --------------------------- -# Stage 2: image produksi +# Stage 2: production image # --------------------------- FROM node:18-alpine WORKDIR /app -# Hanya copy file hasil build dari stage sebelumnya +# Copy hasil build dari stage sebelumnya COPY --from=builder /app/build ./build -COPY package*.json ./ -# Install hanya dependency production -RUN npm ci --only=production && npm cache clean --force +# Install serve untuk menyajikan React app +RUN npm install -g serve && npm cache clean --force # Ubah kepemilikan agar aman di Kubernetes RUN chown -R node:node /app @@ -38,5 +36,5 @@ USER node # Expose port EXPOSE 3000 -# Jalankan app (gunakan serve untuk app React, atau npm start kalau Node server) -CMD ["npx", "serve", "-s", "build"] +# Jalankan app React statis +CMD ["serve", "-s", "build"]