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 # Copy the full project and install it as a package.
0037 COPY . /build/swf-monitor
0038 RUN pip install --no-cache-dir -e /build/swf-monitor
0039
0040 # Collect static files. We set only the variables that settings.py requires at
0041 # import time; the real values come from the environment at runtime.
0042 RUN SECRET_KEY="build-placeholder" \
0043 DB_HOST=localhost \
0044 DJANGO_LOGGING_MODE=none \
0045 python /build/swf-monitor/src/manage.py collectstatic --noinput || true
0046
0047 # --------------- runtime stage: slim image -----------------------------------
0048 FROM python:3.11-slim
0049
0050 RUN apt-get update && apt-get install -y --no-install-recommends \
0051 libpq5 curl \
0052 && rm -rf /var/lib/apt/lists/*
0053
0054 # Bring over installed packages and collected static files from the builder.
0055 COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
0056 COPY --from=builder /usr/local/bin /usr/local/bin
0057 COPY --from=builder /build/swf-monitor /app
0058 COPY --from=builder /build/swf-common-lib /opt/swf-common-lib
0059
0060 WORKDIR /app/src
0061
0062 # Entrypoint handles migrations + server start.
0063 COPY docker-entrypoint.sh /docker-entrypoint.sh
0064 RUN chmod +x /docker-entrypoint.sh
0065
0066 EXPOSE 8000
0067
0068 ENTRYPOINT ["/docker-entrypoint.sh"]
0069 CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "swf_monitor_project.asgi:application"]