VArious admin fixes
This commit is contained in:
+23
-3
@@ -34,9 +34,11 @@ FROM python:3.11-slim
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PATH="/opt/venv/bin:$PATH" \
|
||||
DATABASE_TYPE=sqlite \
|
||||
DATABASE_TYPE=postgresql \
|
||||
FLASK_ENV=production \
|
||||
FLASK_APP=main.py
|
||||
FLASK_APP=main.py \
|
||||
FLASK_RUN_HOST=0.0.0.0 \
|
||||
FLASK_RUN_PORT=5000
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
@@ -61,6 +63,24 @@ COPY --chown=appuser:appuser . .
|
||||
RUN mkdir -p /app/data /app/logs && \
|
||||
chown -R appuser:appuser /app/data /app/logs
|
||||
|
||||
# Create a startup script for better initialization
|
||||
RUN echo '#!/bin/bash\n\
|
||||
# Wait for database to be ready\n\
|
||||
echo "Waiting for database connection..."\n\
|
||||
while ! python -c "import psycopg2; psycopg2.connect(host=\"$DB_HOST\", port=\"$DB_PORT\", user=\"$DB_USER\", password=\"$DB_PASSWORD\", dbname=\"$DB_NAME\")" 2>/dev/null; do\n\
|
||||
echo "Database not ready, waiting..."\n\
|
||||
sleep 2\n\
|
||||
done\n\
|
||||
echo "Database connection established!"\n\
|
||||
\n\
|
||||
# Initialize database if needed\n\
|
||||
python -c "from db_setup import db_config_manager; db_config_manager.load_config(); db_config_manager._update_environment_variables()"\n\
|
||||
\n\
|
||||
# Start the application\n\
|
||||
exec python main.py' > /app/start.sh && \
|
||||
chmod +x /app/start.sh && \
|
||||
chown appuser:appuser /app/start.sh
|
||||
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
@@ -72,4 +92,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:5000/ || exit 1
|
||||
|
||||
# Default command
|
||||
CMD ["python", "main.py"]
|
||||
CMD ["/app/start.sh"]
|
||||
|
||||
Reference in New Issue
Block a user