ARG CONTAINER_REGISTRY=version-control.centurion.localhost

# User Dockerfile
FROM ${CONTAINER_REGISTRY}/flows-wrapper:latest

ARG REPO_NAME=default
ARG BRANCH_NAME=default
ARG VERSION=default
ARG NAMESPACE=default

# Set up working directory
WORKDIR /app

# Copy user-specific files (flows.json, schemas, requirements)
COPY . .

# Install dependencies specific to the flow if requirements.txt exists
RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi

ENV REPO_NAME=$REPO_NAME
ENV BRANCH_NAME=$BRANCH_NAME
ENV VERSION=$VERSION
ENV NAMESPACE=$NAMESPACE

# Run the generator to create the workflow.py
RUN python generator.py --input-file /app/flows.json --output-file /app/workflow.py

# Set the entry point to the worker with the generated workflow
ENTRYPOINT ["python", "/app/flow_wrapper.py"]
