feat: Add purge: false to Woodpecker build and optimize Docker Compose for production with resource limits, log rotation, and a refined database migration command.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,31 +1,39 @@
|
||||
services:
|
||||
app:
|
||||
# Mengambil image dari Registry Gitea Anda
|
||||
image: git.exavolt.web.id/fikri/fullstack-portfolio:latest
|
||||
container_name: fikri-portfolio-app
|
||||
restart: always
|
||||
ports:
|
||||
- "4000:4000"
|
||||
|
||||
# Mengambil variabel dari file .env di folder yang sama
|
||||
# OPTIMASI 1: Cukup gunakan env_file atau environment, jangan keduanya untuk variabel yang sama
|
||||
# Jika variabel sudah ada di .env, Docker akan otomatis memetakan ke container.
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
environment:
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
JWT_SECRET: ${JWT_SECRET}
|
||||
R2_TOKEN: ${R2_TOKEN}
|
||||
R2_ACCESS_KEY: ${R2_ACCESS_KEY}
|
||||
R2_SECRET_KEY: ${R2_SECRET_KEY}
|
||||
R2_ENDPOINT: ${R2_ENDPOINT}
|
||||
R2_BUCKET_NAME: ${R2_BUCKET_NAME}
|
||||
IMAGE_URL: ${IMAGE_URL}
|
||||
# Tambahkan port agar internal container sesuai
|
||||
# OPTIMASI 2: Set Node Environment ke production untuk performa lebih cepat
|
||||
NODE_ENV: production
|
||||
PORT: 4000
|
||||
|
||||
# OPTIMASI 3: Resources Limit (Mencegah VPS hang jika ada memory leak)
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 512M
|
||||
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
# Tetap jalankan migrasi database sebelum start
|
||||
# OPTIMASI 4: Logging limit agar disk VPS tidak penuh oleh log docker
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# OPTIMASI 5: Migrasi Database
|
||||
# Jika image Anda sudah sangat minimal (alpine), pastikan npx tersedia.
|
||||
# Lebih baik migrasi dilakukan di tahap CI atau via script init.
|
||||
command: >
|
||||
sh -c "npx prisma migrate deploy && node server.js"
|
||||
Reference in New Issue
Block a user