From a58441c4d6e8cf13424fca8766880b124e04fc4c Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Thu, 23 Apr 2026 16:32:04 +0800 Subject: [PATCH] feat: run prisma migrate deploy on container startup --- Dockerfile | 4 +++- entrypoint.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 9023548..faf828b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,11 +67,12 @@ COPY --from=builder /app/package.json ./package.json COPY --from=builder /app/tsconfig.json ./tsconfig.json COPY --from=builder /app/prisma ./prisma COPY --from=builder /app/src ./src +COPY entrypoint.sh ./entrypoint.sh # Env vars runtime dikelola oleh Portainer (stack env / container env). # Tidak perlu copy .env ke runner — image tetap bersih tanpa secrets. -RUN chown -R nextjs:nodejs /app +RUN chown -R nextjs:nodejs /app && chmod +x entrypoint.sh USER nextjs @@ -80,4 +81,5 @@ EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" +ENTRYPOINT ["./entrypoint.sh"] CMD ["bun", "run", "start"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..9a9a2b3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +echo "⏳ Menjalankan migrasi database..." +./node_modules/.bin/prisma migrate deploy +echo "✅ Migrasi selesai." + +exec "$@"