fixed migrations

This commit is contained in:
2025-06-02 16:11:56 +02:00
parent c95a1c456b
commit 4dbaa27cba
98 changed files with 399 additions and 109 deletions

View File

@@ -1,33 +1,57 @@
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
postgresql-client \
build-essential \
libpq-dev \
curl \
netcat-traditional \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 celery
# Set working directory
WORKDIR /app
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
# Copy application code
COPY . .
# Create migrations directory if it doesn't exist
RUN mkdir -p migrations/versions
# Create necessary directories and set permissions
RUN mkdir -p /app/uploads /app/static/uploads && \
chown -R celery:celery /app
# Make entrypoint script executable
RUN chmod +x entrypoint.sh
# Create and set up startup script
RUN echo '#!/bin/bash\n\
echo "Waiting for database..."\n\
while ! nc -z db 5432; do\n\
sleep 0.1\n\
done\n\
echo "Database is ready!"\n\
\n\
echo "Waiting for Redis..."\n\
while ! nc -z redis 6379; do\n\
sleep 0.1\n\
done\n\
echo "Redis is ready!"\n\
\n\
echo "Running database migrations..."\n\
flask db upgrade\n\
\n\
echo "Creating admin user..."\n\
flask create-admin\n\
\n\
echo "Starting application..."\n\
exec "$@"' > /app/start.sh && \
chmod +x /app/start.sh && \
chown celery:celery /app/start.sh
# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
# Switch to non-root user
USER celery
# Expose the port the app runs on
EXPOSE 5000
# Use the entrypoint script
ENTRYPOINT ["./entrypoint.sh"]
# Set entrypoint
ENTRYPOINT ["/app/start.sh"]