In a self-packaged ComfyUI project container, if I want to create a workflow endpoint, how can I access the config object from the ComfyUI API?
Hi bro, i’m facing a difficulty—could you take a look and help me out?
In your project, since it's already a Node.js-based project, it's possible to directly import the object from config.js, just like in the example workflow.
import { z } from "zod";
import { ComfyPrompt, Workflow } from "../../src/types";
import config from "../../src/config";
But what if it's a self-packaged ComfyUI container?
The workflows are actually loaded at runtime via eval, within the context of src/workflows, so you can access the config object at
import config from "../config";
But what about self-built container? For example, this is my project structure.
And this is my Dockerfile
ARG base=runtime
ARG pytorch_version=2.7.0
ARG cuda_version=12.8
FROM pytorch/pytorch:${pytorch_version}-cuda${cuda_version}-cudnn9-${base}
ENV DEBIAN_FRONTEND=noninteractive
ENV PIP_PREFER_BINARY=1
ENV CMAKE_BUILD_PARALLEL_LEVEL=8
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
curl \
git \
unzip \
wget \
&& apt clean -y && rm -rf /var/lib/apt/lists/*
# Install comfy-cli, which makes it easy to install custom nodes and other comfy specific functionality.
SHELL ["/bin/bash", "-c"]
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir comfy-cli
WORKDIR /opt
ARG comfy_version=0.3.35
RUN git clone --depth 1 --branch v${comfy_version} https://github.com/comfyanonymous/ComfyUI.git
WORKDIR /opt/ComfyUI
ARG cuda_version=12.8
RUN pip install --no-cache-dir torchaudio --index-url https://download.pytorch.org/whl/cu${cuda_version//./}
RUN pip install --no-cache-dir -r requirements.txt
ENV COMFY_HOME=/opt/ComfyUI
RUN comfy --skip-prompt tracking disable
RUN comfy --skip-prompt set-default ${COMFY_HOME}
ENV MODEL_DIR=${COMFY_HOME}/models
ENV OUTPUT_DIR=${COMFY_HOME}/output
ENV INPUT_DIR=${COMFY_HOME}/input
ENV WORKFLOW_DIR=/workflows
ENV STARTUP_CHECK_MAX_TRIES=30
ENV CMD="comfy --workspace ${COMFY_HOME} launch -- --listen *"
ENV BASE=""
# Install all the comfyui nodes that are required for the comfyui-api to work
RUN comfy node registry-install comfyui-manager
RUN comfy node registry-install cg-use-everywhere
RUN comfy node registry-install comfyui_controlnet_aux
RUN comfy node registry-install comfyui_essentials
RUN comfy node registry-install comfyui_instantid
RUN comfy node registry-install comfyui_ipadapter_plus
RUN comfy node registry-install ComfyUI-Crystools
RUN comfy node registry-install comfyui-custom-scripts
RUN comfy node registry-install ComfyUI-GGUF
RUN comfy node registry-install comfyui-impact-pack
RUN comfy node registry-install comfyui-impact-subpack
RUN comfy node registry-install comfyui-wd14-tagger
RUN comfy node registry-install wsa-node-suite-comfyui
# Copy Models
COPY models /opt/ComfyUI/models
# Copy Workflows
COPY workflows /opt/ComfyUI/workflows
# Change this to the version you want to use
ARG api_version=1.8.3
# Download the comfyui-api binary, and make it executable
ADD https://github.com/SaladTechnologies/comfyui-api/releases/download/${api_version}/comfyui-api .
RUN chmod +x comfyui-api
docker-compose.yaml
services:
comfyui:
build:
context: .
dockerfile: Dockerfile
volumes:
- type: bind
source: ./output
target: /opt/ComfyUI/output
- type: bind
source: ./input
target: /opt/ComfyUI/input
command: ["/opt/ComfyUI/comfyui-api"]
ports:
- "3000:3000"
- "8188:8188"
environment:
LOG_LEVEL: "debug"
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [ gpu ]
count: all
Yes, even in a self built container, the workflow is evaluated at src/workflows.
Thanks for your help. I found the problem in my code — it was an issue with the workflow folder path.