fully working when deployed

This commit is contained in:
2025-09-28 18:47:31 +01:00
parent 38ee5a8886
commit d4aa460f91
9 changed files with 303 additions and 81 deletions
+17 -28
View File
@@ -34,41 +34,29 @@ WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Create system user and group
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy necessary files from builder stage
COPY --from=builder /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=root:root /app/.next/static ./.next/static
# Copy full node_modules for database operations
COPY --from=builder /app/node_modules ./node_modules
# Copy database setup scripts and package.json
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts
COPY --from=builder /app/package.json ./package.json
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create public directory if it doesn't exist
RUN mkdir -p public
# Create directories for data and backups
RUN mkdir -p /app/data /app/backups /app/logs && \
chown -R nextjs:nodejs /app/data /app/backups /app/logs
RUN mkdir -p /app/data /app/backups /app/logs
# Create startup script
COPY --chown=nextjs:nodejs <<EOF /app/start.sh
#!/bin/sh
set -e
echo "🚀 Starting TT Booking Production..."
# Ensure database directory has proper permissions
if [ -d "/app/data" ]; then
echo "📁 Setting database permissions..."
chmod -R 755 /app/data /app/backups /app/logs 2>/dev/null || true
if [ -f "/app/data/sqlite.db" ]; then
chmod 644 /app/data/sqlite.db 2>/dev/null || true
fi
fi
echo "🌟 Starting server..."
exec node server.js
EOF
RUN chmod +x /app/start.sh
EXPOSE 3000
ENV PORT=3000
@@ -78,4 +66,5 @@ ENV HOSTNAME="0.0.0.0"
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:3000/api/health || exit 1
CMD ["/app/start.sh"]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]