Files
ciaovolo/flight-comparator/Dockerfile
domverse 260f3aa196 fix: add web app deps and git to Docker build
- Added fastapi, uvicorn, pydantic, requests to requirements.txt
  (were missing — only CLI deps were present)
- Changed fast-flights entry to git+GitHub URL (v3 not on PyPI)
- Added git to apt-get install in Dockerfile (needed for pip git+ URL)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 15:42:11 +01:00

56 lines
1.7 KiB
Docker

# ── Stage 1: Build React frontend ─────────────────────────────────────────
FROM node:20-alpine AS frontend-builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ .
RUN npm run build
# ── Stage 2: Single runtime image ─────────────────────────────────────────
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1
# Install nginx, supervisor, and gcc (for some pip packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx \
supervisor \
gcc \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Backend source
COPY api_server.py airports.py cache.py ./
COPY database/ ./database/
# Frontend build output
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
# Config files
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisor/conf.d/app.conf
# Remove the default nginx site
RUN rm -f /etc/nginx/sites-enabled/default
# Pre-fetch airport data and initialise the database at build time
RUN mkdir -p data && \
python -c "from airports import download_and_build_airport_data; download_and_build_airport_data()" && \
python database/init_db.py
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget -q --spider http://localhost/ || exit 1
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/conf.d/app.conf"]