update docker frontend for gitops

This commit is contained in:
Syifa 2025-10-22 13:58:36 +07:00
parent 69d55ddc6a
commit 7860305448
2 changed files with 31 additions and 9 deletions

View File

@ -1,4 +1,7 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore
Dockerfile
README.md

View File

@ -1,23 +1,42 @@
FROM node:18-alpine
# Gunakan base image yang lebih ringan
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package.json & package-lock.json (kalau ada)
# Copy package.json dan package-lock.json
COPY package*.json ./
# Install dependencies production-only
RUN npm install --only=production
# Install dependencies (termasuk dev) di stage build
RUN npm ci
# Copy source code
# Copy semua source code
COPY . .
# Build React app (kalau ini frontend)
RUN npm run build
# ---------------------------
# Stage 2: image produksi
# ---------------------------
FROM node:18-alpine
WORKDIR /app
# Hanya copy file 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
# Ubah kepemilikan agar aman di Kubernetes
RUN chown -R node:node /app
USER node
# Expose port 3000
# Expose port
EXPOSE 3000
# Jalankan app
CMD ["npm", "start"]
# Jalankan app (gunakan serve untuk app React, atau npm start kalau Node server)
CMD ["npx", "serve", "-s", "build"]