Skip to content

Commit 4bc8353

Browse files
committed
chore: update Docker configuration to include environment variables for Vite and adjust build process
1 parent 0c1c89f commit 4bc8353

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
depends_on:
2525
- db
2626
backend:
27-
build:
27+
build:
2828
context: ./backend
2929
dockerfile: Dockerfile
3030
target: production
@@ -49,7 +49,11 @@ services:
4949
- "${FE_PORT:-3000}:80"
5050
environment:
5151
- NODE_ENV=production
52+
- VITE_API_URL=${VITE_API_URL}
53+
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
54+
- LOG_LEVEL=${LOG_LEVEL}
5255
depends_on:
5356
- backend
57+
5458
volumes:
5559
pgdata:

frontend/Dockerfile

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
# =========================
1+
# =========================
22
# STAGE 1: BASE
33
# =========================
44
FROM node:22-alpine AS base
55
WORKDIR /app
66

7-
# Salin hanya file yang diperlukan untuk install dependencies
87
COPY package*.json ./
9-
10-
# Pastikan npm up-to-date
118
RUN npm install -g npm@11
129

1310
# =========================
1411
# STAGE 2: DEPENDENCIES
1512
# =========================
1613
FROM base AS deps
17-
# Gunakan npm install agar kompatibel untuk dev dan prod
1814
RUN npm install
1915

2016
# =========================
2117
# STAGE 3: BUILD (Production)
2218
# =========================
2319
FROM deps AS builder
20+
21+
# --- Tambahan ENV untuk Vite ---
22+
ARG VITE_API_URL
23+
ARG DISCORD_WEBHOOK_URL
24+
ARG LOG_LEVEL
25+
26+
ENV VITE_API_URL=$VITE_API_URL
27+
ENV DISCORD_WEBHOOK_URL=$DISCORD_WEBHOOK_URL
28+
ENV LOG_LEVEL=$LOG_LEVEL
29+
# --------------------------------
30+
2431
COPY . .
2532
RUN npm run build
2633

@@ -29,33 +36,21 @@ RUN npm run build
2936
# =========================
3037
FROM deps AS development
3138
ENV NODE_ENV=development
32-
# Disable file watching performance warning
3339
ENV WATCHPACK_POLLING=true
3440
ENV CHOKIDAR_USEPOLLING=true
3541
ENV CHOKIDAR_INTERVAL=500
3642

37-
# Copy source agar hot reload tetap berfungsi saat tanpa volume
3843
COPY . .
3944

40-
# Port default Vite atau Nest dev server
4145
EXPOSE 5173
42-
43-
# Ganti user agar tidak pakai root (best practice)
44-
# USER node
45-
46-
# Jalankan dev mode
4746
CMD ["npm", "run", "dev"]
4847

4948
# =========================
5049
# STAGE 5: PRODUCTION
5150
# =========================
5251
FROM nginx:alpine AS production
5352

54-
# Copy hasil build ke nginx
5553
COPY --from=builder /app/dist /usr/share/nginx/html
5654

57-
# Optional custom config
58-
# COPY nginx.conf /etc/nginx/conf.d/default.conf
59-
6055
EXPOSE 80
6156
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)