From feca755b8b0777d5bea489f3d13e4fe236b8b2c5 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 13 Jun 2025 23:38:15 +0100 Subject: [PATCH] feat: run migrations via entrypoint --- apps/web/Dockerfile | 3 +-- apps/web/entrypoint.sh | 16 ++++++++++++++++ apps/web/next.config.js | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 apps/web/entrypoint.sh diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index ecdfe2c7..d898e44b 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -75,6 +75,5 @@ ARG PORT=3000 ENV PORT=${PORT} EXPOSE ${PORT} -# Run migration on start for now (until we have a better way to handle this) -CMD ["sh", "-c", "cd /app && pnpm db:migrate && cd /app/apps/web && pnpm start"] +CMD ["./entrypoint.sh"] diff --git a/apps/web/entrypoint.sh b/apps/web/entrypoint.sh new file mode 100644 index 00000000..85557067 --- /dev/null +++ b/apps/web/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Run migrations from the Turborepo root context +echo "Running database migrations..." +# Navigate to the Turborepo root to run the db:migrate command +pnpm --prefix /app db:migrate + +# Check if migration was successful +if [ $? -ne 0 ]; then + echo "\nDatabase migration failed! Exiting." + exit 1 +fi + +echo "\nStarting Next.js application..." +# Start the Next.js application from the web app's directory +exec node .next/standalone/apps/web/server.js \ No newline at end of file diff --git a/apps/web/next.config.js b/apps/web/next.config.js index e909fa3c..08f0f5d2 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -10,6 +10,7 @@ configureRuntimeEnv(); /** @type {import("next").NextConfig} */ const config = { + output: "standalone", reactStrictMode: true, /** Enables hot reloading for local packages without a build step */