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:
@@ -7,6 +7,7 @@ steps:
|
|||||||
repo: git.exavolt.web.id/fikri/fullstack-portfolio
|
repo: git.exavolt.web.id/fikri/fullstack-portfolio
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
use_cache: true
|
use_cache: true
|
||||||
|
purge: false
|
||||||
username:
|
username:
|
||||||
from_secret: gitea_user
|
from_secret: gitea_user
|
||||||
password:
|
password:
|
||||||
|
|||||||
@@ -1,31 +1,39 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
# Mengambil image dari Registry Gitea Anda
|
|
||||||
image: git.exavolt.web.id/fikri/fullstack-portfolio:latest
|
image: git.exavolt.web.id/fikri/fullstack-portfolio:latest
|
||||||
container_name: fikri-portfolio-app
|
container_name: fikri-portfolio-app
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- "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_file:
|
||||||
- .env
|
- .env
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: ${DATABASE_URL}
|
# OPTIMASI 2: Set Node Environment ke production untuk performa lebih cepat
|
||||||
JWT_SECRET: ${JWT_SECRET}
|
NODE_ENV: production
|
||||||
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
|
|
||||||
PORT: 4000
|
PORT: 4000
|
||||||
|
|
||||||
|
# OPTIMASI 3: Resources Limit (Mencegah VPS hang jika ada memory leak)
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512M
|
||||||
|
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "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: >
|
command: >
|
||||||
sh -c "npx prisma migrate deploy && node server.js"
|
sh -c "npx prisma migrate deploy && node server.js"
|
||||||
Reference in New Issue
Block a user