Warning, /swf-testbed/Dockerfile is written in an unsupported language. File is not indexed.
0001 # =============================================================================
0002 # Dockerfile for swf-testbed — CLI + workflow agents
0003 # =============================================================================
0004 # Build context: the repository root (parent of swf-testbed, swf-monitor, etc.)
0005 #
0006 # The image installs swf-common-lib, swf-monitor, and swf-testbed so that the
0007 # `testbed run` CLI works out of the box inside a container.
0008 # =============================================================================
0009
0010 # --------------- build stage: install all deps -------------------------------
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 # Copy the three repos into the build context.
0020 # Build context is the monorepo root so paths are relative to it.
0021 COPY swf-common-lib /build/swf-common-lib
0022 COPY swf-monitor /build/swf-monitor
0023 COPY swf-testbed /build/swf-testbed
0024
0025 # 1. swf-common-lib (shared utilities)
0026 RUN pip install --no-cache-dir /build/swf-common-lib
0027
0028 # 2. swf-monitor dependencies + package
0029 RUN pip install --no-cache-dir -r /build/swf-monitor/requirements.txt \
0030 && pip install --no-cache-dir django-mcp-server django-oauth-toolkit uvicorn \
0031 && pip install --no-cache-dir /build/swf-monitor
0032
0033 # 3. swf-epicprod (production applications installed into the monitor runtime;
0034 # provides the pcs package in swf-monitor's INSTALLED_APPS). Cloned from
0035 # GitHub so the build context stays the three-repo checkout; override with
0036 # --build-arg SWF_EPICPROD_REF=<branch|tag> if needed.
0037 ARG SWF_EPICPROD_REF=main
0038 RUN git clone --depth 1 --branch "${SWF_EPICPROD_REF}" \
0039 https://github.com/BNLNPPS/swf-epicprod.git /build/swf-epicprod \
0040 && pip install --no-cache-dir /build/swf-epicprod
0041
0042 # 4. snapper-ai (generic coherent-state history installed in the monitor
0043 # runtime and declared by the swf-testbed meta-package).
0044 ARG SNAPPER_AI_REF=main
0045 RUN git clone --depth 1 --branch "${SNAPPER_AI_REF}" \
0046 https://github.com/BNLNPPS/snapper-ai.git /build/snapper-ai \
0047 && pip install --no-cache-dir /build/snapper-ai
0048
0049 # 5. swf-testbed itself (typer CLI, supervisor, psutil, simpy, etc.)
0050 RUN pip install --no-cache-dir /build/swf-testbed
0051
0052 # --------------- runtime stage: slim image -----------------------------------
0053 FROM python:3.11-slim
0054
0055 RUN apt-get update && apt-get install -y --no-install-recommends \
0056 libpq5 wget \
0057 && rm -rf /var/lib/apt/lists/*
0058
0059 # Bring over installed packages from the builder.
0060 COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
0061 COPY --from=builder /usr/local/bin /usr/local/bin
0062
0063 # Copy the testbed source tree (needed at runtime for workflows/, example_agents/, configs).
0064 COPY --from=builder /build/swf-testbed /app
0065 # Keep swf-monitor source available (manage.py for migrations, etc.)
0066 COPY --from=builder /build/swf-monitor /opt/swf-monitor
0067 COPY --from=builder /build/swf-common-lib /opt/swf-common-lib
0068
0069 WORKDIR /app
0070
0071 # Create logs directory that supervisord expects.
0072 RUN mkdir -p /app/logs
0073
0074 # Symlinks so that $SWF_HOME/swf-testbed resolves to /app regardless of
0075 # which path _setup_environment() computes for SWF_HOME.
0076 # agents.supervisord.conf uses: directory=%(ENV_SWF_HOME)s/swf-testbed
0077 RUN ln -s /app /opt/swf-testbed && ln -s /app /usr/local/lib/swf-testbed
0078
0079 # Entrypoint handles environment setup, then runs the requested command.
0080 COPY swf-testbed/docker-entrypoint.sh /docker-entrypoint.sh
0081 RUN chmod +x /docker-entrypoint.sh
0082
0083 ENTRYPOINT ["/docker-entrypoint.sh"]
0084 CMD ["testbed", "run"]