From 5e544afdae72ecd40b52c1169e95b0a714fde2d3 Mon Sep 17 00:00:00 2001 From: denshooter Date: Thu, 15 Jan 2026 17:01:39 +0100 Subject: [PATCH] chore: Update Docker configuration and Gitea deployment workflow - Added a new script for database migration to the Docker image. - Adjusted Dockerfile to create the scripts directory and copy the migration script with the correct permissions. - Enhanced the Gitea deployment workflow to ensure the proxy network exists before starting the container. --- .dockerignore | 1 + .gitea/workflows/dev-deploy.yml | 10 ++++++++++ Dockerfile | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 9d7cfe8..b409662 100644 --- a/.dockerignore +++ b/.dockerignore @@ -57,6 +57,7 @@ docker-compose*.yml # Scripts (keep only essential ones) scripts !scripts/init-db.sql +!scripts/start-with-migrate.js # Misc .cache diff --git a/.gitea/workflows/dev-deploy.yml b/.gitea/workflows/dev-deploy.yml index d9160d7..e3822be 100644 --- a/.gitea/workflows/dev-deploy.yml +++ b/.gitea/workflows/dev-deploy.yml @@ -158,11 +158,21 @@ jobs: fi fi + # Ensure proxy network exists + echo "🌐 Checking for proxy network..." + if ! docker network inspect proxy >/dev/null 2>&1; then + echo "⚠️ Proxy network not found, creating it..." + docker network create proxy 2>/dev/null || echo "Network might already exist or creation failed" + else + echo "✅ Proxy network exists" + fi + # Start new container with updated image echo "🆕 Starting new dev container..." docker run -d \ --name $CONTAINER_NAME \ --restart unless-stopped \ + --network proxy \ -p ${HEALTH_PORT}:3000 \ -e NODE_ENV=production \ -e LOG_LEVEL=${LOG_LEVEL:-debug} \ diff --git a/Dockerfile b/Dockerfile index 820f9de..2487baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,7 +66,6 @@ RUN adduser --system --uid 1001 nextjs # Copy the built application COPY --from=builder /app/public ./public -COPY --from=builder /app/scripts ./scripts # Set the correct permission for prerender cache RUN mkdir .next @@ -86,6 +85,10 @@ COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma COPY --from=builder /app/node_modules/prisma ./node_modules/prisma COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma +# Create scripts directory and copy start script AFTER standalone to ensure it's not overwritten +RUN mkdir -p scripts && chown nextjs:nodejs scripts +COPY --from=builder --chown=nextjs:nodejs /app/scripts/start-with-migrate.js ./scripts/start-with-migrate.js + # Note: Environment variables should be passed via docker-compose or runtime environment # DO NOT copy .env files into the image for security reasons