Warning, /swf-monitor/Dockerfile is written in an unsupported language. File is not indexed.
0001 # =============================================================================
0002 # Dockerfile for swf-monitor — Django 4.2 / Daphne ASGI
0003 # =============================================================================
0004 # Build context: the swf-monitor repository root.
0005 #
0006 # The image clones the sibling swf-common-lib from GitHub so the container is
0007 # fully self-contained (no host-mount of sibling repos required at runtime).
0008 # =============================================================================
0009
0010 # --------------- build stage: install deps, collect static -------------------
0011 FROM python:3.11-slim AS builder
0012
0013 RUN apt-get update && apt-get install -y --no-install-recommends \
0014 build-essential libpq-dev libffi-dev git \
0015 && rm -rf /var/lib/apt/lists/*
0016
0017 WORKDIR /build
0018
0019 # Clone swf-common-lib (shared utilities used by the logging subsystem).
0020 # Pin to main; override with --build-arg SWF_COMMON_REF=<branch|tag> if needed.
0021 ARG SWF_COMMON_REF=main
0022 RUN git clone --depth 1 --branch "${SWF_COMMON_REF}" \
0023 https://github.com/BNLNPPS/swf-common-lib.git /build/swf-common-lib
0024
0025 # Install swf-common-lib first (it is a dependency of swf-monitor).
0026 RUN pip install --no-cache-dir /build/swf-common-lib
0027
0028 # Install swf-monitor's own Python dependencies.
0029 COPY requirements.txt .
0030 RUN pip install --no-cache-dir -r requirements.txt
0031
0032 # Install packages that are referenced in INSTALLED_APPS / settings but absent
0033 # from requirements.txt (they ship as separate PyPI packages).
0034 RUN pip install --no-cache-dir django-mcp-server django-oauth-toolkit uvicorn
0035
0036 # Install snapper-ai, the generic Django application providing coherent state
0037 # history. It is a separately versioned sibling in development and must be
0038 # present before Django imports INSTALLED_APPS during image construction.
0039 ARG SNAPPER_AI_REF=main
0040 RUN git clone --depth 1 --branch "${SNAPPER_AI_REF}" \
0041 https://github.com/BNLNPPS/snapper-ai.git /build/snapper-ai \
0042 && pip install --no-cache-dir /build/snapper-ai
0043
0044 # Copy the full project and install it as a package.
0045 COPY . /build/swf-monitor
0046 RUN pip install --no-cache-dir -e /build/swf-monitor
0047
0048 # Clone and install swf-epicprod (production applications installed into the
0049 # monitor runtime; provides the pcs package in INSTALLED_APPS). Same
0050 # self-contained pattern as swf-common-lib above.
0051 ARG SWF_EPICPROD_REF=main
0052 RUN git clone --depth 1 --branch "${SWF_EPICPROD_REF}" \
0053 https://github.com/BNLNPPS/swf-epicprod.git /build/swf-epicprod \
0054 && pip install --no-cache-dir /build/swf-epicprod
0055
0056 # Collect static files. We set only the variables that settings.py requires at
0057 # import time; the real values come from the environment at runtime.
0058 RUN SECRET_KEY="build-placeholder" \
0059 DB_HOST=localhost \
0060 DJANGO_LOGGING_MODE=none \
0061 python /build/swf-monitor/src/manage.py collectstatic --noinput || true
0062
0063 # --------------- runtime stage: slim image -----------------------------------
0064 FROM python:3.11-slim
0065
0066 RUN apt-get update && apt-get install -y --no-install-recommends \
0067 libpq5 curl \
0068 && rm -rf /var/lib/apt/lists/*
0069
0070 # Bring over installed packages and collected static files from the builder.
0071 COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
0072 COPY --from=builder /usr/local/bin /usr/local/bin
0073 COPY --from=builder /build/swf-monitor /app
0074 COPY --from=builder /build/swf-common-lib /opt/swf-common-lib
0075
0076 WORKDIR /app/src
0077
0078 # Entrypoint handles migrations + server start.
0079 COPY docker-entrypoint.sh /docker-entrypoint.sh
0080 RUN chmod +x /docker-entrypoint.sh
0081
0082 EXPOSE 8000
0083
0084 ENTRYPOINT ["/docker-entrypoint.sh"]
0085 CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "swf_monitor_project.asgi:application"]