diff --git a/Dockerfile b/Dockerfile index bba5a399..d7dbc7e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,9 +59,10 @@ COPY --from=builder --chown=nextjs:nodejs /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma COPY --from=builder --chown=nextjs:nodejs /app/next.config.* ./ +COPY --chmod=755 docker-entrypoint.sh ./docker-entrypoint.sh USER nextjs EXPOSE 3000 -CMD ["bun", "start"] \ No newline at end of file +CMD ["/app/docker-entrypoint.sh"] \ No newline at end of file diff --git a/QWEN.md b/QWEN.md index 3e0d9347..c1070959 100644 --- a/QWEN.md +++ b/QWEN.md @@ -250,3 +250,24 @@ Setelah commit ke branch deployment (dev/stg/prod), otomatis trigger workflow pu Branch deployment: `stg` (staging) atau `prod` (production) Version format di package.json: `"version": "major.minor.patch"` +- **Deployment Workflow HARUS Sequential (Berurutan)**: + +Saat deploy ke stg atau prod, workflow TIDAK BOLEH dijalankan bersamaan. Harus menunggu yang pertama SELESAI total baru trigger yang kedua. + +**Urutan yang BENAR:** +1. ✅ **publish.yml** - Tunggu sampai SELESAI (status: ✓ success) +2. ✅ **Setelah publish selesai**, baru trigger **re-pull.yml** + +**JANGAN trigger keduanya bersamaan!** Ini akan menyebabkan race condition karena re-pull akan menarik image yang belum selesai di-build. + +**Cara cek workflow selesai:** +```bash +gh run view --json status --jq '.status' +# Harus return "completed" baru lanjut ke re-pull +``` + +**Atau polling sampai selesai:** +```bash +gh run watch +# Tunggu sampai ada checkmark ✓ +``` diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..e0b6e6bc --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +echo "🔄 Running database migrations..." +cd /app +bunx prisma migrate deploy || { + echo "❌ Migration failed!" + exit 1 +} +echo "✅ Migrations completed successfully" + +echo "🚀 Starting application..." +exec bun start