# Backend Dockerfile for Flight Radar API FROM python:3.11-slim # Set working directory WORKDIR /app # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/* # Copy requirements file COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY api_server.py . COPY airports.py . COPY cache.py . COPY database/ ./database/ # Create necessary directories RUN mkdir -p data # Download airport data on build RUN python -c "from airports import download_and_build_airport_data; download_and_build_airport_data()" # Initialize database RUN python database/init_db.py # Expose port EXPOSE 8000 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD python -c "import requests; requests.get('http://localhost:8000/health').raise_for_status()" # Run the application CMD ["python", "api_server.py"]