2026-02-03 12:27:34 +09:00
|
|
|
# Backend Dockerfile for Galaxy-PO
|
|
|
|
|
FROM python:3.12-slim
|
2026-02-02 23:05:41 +09:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-02-04 22:26:19 +09:00
|
|
|
# Install system dependencies and uv
|
|
|
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
|
|
|
|
|
2026-02-02 23:05:41 +09:00
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
gcc \
|
|
|
|
|
libpq-dev \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-02-04 22:26:19 +09:00
|
|
|
# Install Python dependencies with uv
|
|
|
|
|
COPY pyproject.toml .
|
|
|
|
|
RUN uv pip install --system --no-cache -r pyproject.toml
|
2026-02-02 23:05:41 +09:00
|
|
|
|
|
|
|
|
# Copy application code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
2026-02-03 12:27:34 +09:00
|
|
|
# Create non-root user for security
|
|
|
|
|
RUN adduser --disabled-password --gecos '' appuser && \
|
|
|
|
|
chown -R appuser:appuser /app
|
|
|
|
|
USER appuser
|
|
|
|
|
|
2026-02-02 23:05:41 +09:00
|
|
|
# Expose port
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
2026-02-03 12:27:34 +09:00
|
|
|
# Health check
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
|
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
|
|
|
|
|
|
2026-02-07 10:25:14 +09:00
|
|
|
# Run migrations and start the application
|
|
|
|
|
CMD ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000"]
|