# exocortex-project: the Plane fork image, built from the server code the wheel carries.
# Build context (written by `plane up --docker`): api/ (apps/api), web/ (the SPA build),
# entrypoint.sh. Only the python base image is pulled; every dependency comes from pip.
ARG PYTHON_IMAGE=python:3.12-slim
FROM ${PYTHON_IMAGE}

ARG PIP_INDEX_URL=https://pypi.org/simple
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_INDEX_URL=${PIP_INDEX_URL} \
    DJANGO_SETTINGS_MODULE=plane.settings.production \
    PLANE_SERVE_WEB_DIR=/web

WORKDIR /code

# psycopg-c compiles against libpq; psycopg-binary (also pinned) is the same driver as a wheel,
# so the slim image needs no compiler.
COPY api/requirements.txt ./requirements.txt
COPY api/requirements ./requirements
RUN sed -i '/^psycopg-c/d' requirements/base.txt \
    && pip install --no-cache-dir -r requirements.txt

COPY api/ /code/
COPY web/ /web/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && mkdir -p /code/plane/logs

ENTRYPOINT ["/entrypoint.sh"]
CMD ["api"]
