hcm21 / server /Dockerfile
ParetoOptimal's picture
Optimize Docker build: add .dockerignore, layer caching, drop editable install
20f0740
Raw
History Blame Contribute Delete
743 Bytes
FROM python:3.12-slim
WORKDIR /app
# Install dependencies first (cached layer on rebuilds)
COPY pyproject.toml README.md openenv.yaml ./
RUN mkdir -p hr_env server agent && \
touch hr_env/__init__.py server/__init__.py agent/__init__.py && \
pip install --no-cache-dir ".[server]"
# Copy actual source
COPY hr_env/ hr_env/
COPY server/ server/
# Reinstall project only (deps already installed above)
RUN pip install --no-cache-dir --no-deps .
ENV ENABLE_WEB_INTERFACE=true
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]