FROM python:3.12-slim

RUN apt-get update && apt-get install -y --no-install-recommends openssl && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements-dashboard.txt /tmp/requirements.txt
COPY requirements-constraints.txt /tmp/requirements-constraints.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

COPY app.py accounts.py ./
COPY manager-agent/startup_commands.py ./startup_commands.py
COPY manager-agent/game_templates.py manager-agent/generic_templates.py manager-agent/template_library.py manager-agent/update_preservation.py ./manager-agent/
COPY manager-agent/generic-game-templates/ ./manager-agent/generic-game-templates/
RUN chmod 700 manager-agent/generic-game-templates && chmod 600 manager-agent/generic-game-templates/*.json
COPY manager-agent/runtime_adapters.py ./manager-agent/
COPY manager-agent/engine_bootstrap.py manager-agent/template_engine_store.py manager-agent/template_engine_probe.py manager-agent/template_engine_control.py manager-agent/template-engine-api.json manager-agent/template-engine-publisher.pem ./manager-agent/
COPY manager-agent/custom_download.py manager-agent/custom_templates.py manager-agent/template_setup.py manager-agent/template_creator.py manager-agent/manual_templates.py manager-agent/manual_install.py manager-agent/amp_import.py manager-agent/amp_catalog.py manager-agent/start_ports.py manager-agent/manual_ports.py ./manager-agent/
COPY templates/ templates/
COPY static/ static/

EXPOSE 8095

CMD ["gunicorn", "--bind", "0.0.0.0:8095", "--workers", "2", "app:app"]
