From d1849774d950f63cfad246d46be2ee363f4c7f6c Mon Sep 17 00:00:00 2001 From: June Date: Tue, 17 Feb 2026 18:52:31 +1300 Subject: [PATCH] add entrypoint for db migration push --- .gitignore | 1 + Dockerfile | 11 +++++++++-- compose.yaml | 1 + entrypoint.sh | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore index 3b462cb..30e4cdd 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ Thumbs.db .env.* !.env.example !.env.test +pgdata # Vite vite.config.js.timestamp-* diff --git a/Dockerfile b/Dockerfile index 301f920..85d0ab8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,15 @@ RUN pnpm install --frozen-lockfile --prod # Copy built application from builder COPY --from=builder /app/build ./build +# Install netcat for health checks +RUN apk add --no-cache netcat-openbsd + +# Copy entrypoint script +COPY entrypoint.sh /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh + # Expose port (SvelteKit Node adapter default) -EXPOSE 5173 +EXPOSE 3000 # Start the application -CMD ["node", "build"] +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/compose.yaml b/compose.yaml index 7bf5cfb..644be24 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,6 +9,7 @@ services: POSTGRES_PASSWORD: mysecretpassword POSTGRES_DB: memento volumes: + # - ~/tmp/pgdata:/var/lib/postgresql - ./pgdata:/var/lib/postgresql app: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..43d924f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Wait for PostgreSQL to be ready +while ! nc -z db 5432; do + sleep 1 +done + +# Run database migrations +echo "Pushing database schema..." +pnpm run db:push + +# Start the application +echo "Starting application..." +node build