update docker frontend for gitops
This commit is contained in:
parent
69d55ddc6a
commit
7860305448
|
|
@ -1,4 +1,7 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.git
|
||||
.gitignore
|
||||
Dockerfile
|
||||
README.md
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue