Till Tomczak b65478ed57 Behebe DNS-Timeouts und Image-Pull-Probleme
- Konfiguriere Google DNS Server (8.8.8.8, 8.8.4.4) für zuverlässigere Auflösung
- Füge intelligente Erkennung vorhandener Docker-Images hinzu
- Aktualisiere Dockerfile automatisch, um verfügbare Base-Images zu nutzen
- Verwende generischere Image-Tags (node:alpine, python:slim) als Standard
- Implementiere Fallback mit mehreren alternativen Image-Versionen

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-01 10:09:04 +02:00

52 lines
1.4 KiB
Docker
Executable File

FROM python:slim
WORKDIR /app
# Install system dependencies (curl, sqlite3 for database, wget for healthcheck)
RUN apt-get update && apt-get install -y \
curl \
sqlite3 \
wget \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create required directories
RUN mkdir -p logs instance
ENV FLASK_APP=app.py
ENV PYTHONUNBUFFERED=1
# Add health check endpoint
RUN echo 'from flask import Blueprint\n\
health_bp = Blueprint("health", __name__)\n\
\n\
@health_bp.route("/health")\n\
def health_check():\n\
return {"status": "healthy"}, 200\n'\
> /app/health.py
# Add the health blueprint to app.py if it doesn't exist
RUN grep -q "health_bp" app.py || sed -i '/from flask import/a from health import health_bp' app.py
RUN grep -q "app.register_blueprint(health_bp)" app.py || sed -i '/app = Flask/a app.register_blueprint(health_bp)' app.py
EXPOSE 5000
# Add startup script to initialize database if needed
RUN echo '#!/bin/bash\n\
if [ ! -f "instance/myp.db" ] || [ ! -s "instance/myp.db" ]; then\n\
echo "Initializing database..."\n\
python -c "from app import init_db; init_db()"\n\
fi\n\
\n\
echo "Starting gunicorn server..."\n\
gunicorn --bind 0.0.0.0:5000 app:app\n'\
> /app/start.sh && chmod +x /app/start.sh
CMD ["/app/start.sh"]