Cloning a Git Repo with Docker ENTRYPOINT for.a Flow Run

Some users don’t want to re-build the image each time there are changes to the Git repo. Instead, they want to just clone and install the Git repo during runtime. Here is one such example provided by a user in the community.

Dockerfile:

COPY entry.sh /opt/prefect/
ENTRYPOINT [ "./entry.sh" ]

entry.sh:

#!/bin/bash

git init
git remote add origin https://github.com/<your_repo>.git
git fetch
git checkout -t origin/$GITHUB_REPO_BRANCH -f
[[ $REINSTALL_REQUIREMENTS -eq 1 ]] && pip install -r requirements.txt
[[ $REINSTALL_PY_PACKAGE -eq 1 ]] && pip install -e .
exec "$@"
register_flows.py: Added GITHUB_REPO_BRANCH environment variable to the ECS run.
ecs_run = ECSRun(
    //... other settings
    //...
    // Override these env variables to try different code
    env={'GITHUB_REPO_BRANCH': 'trunk', 'REINSTALL_REQUIREMENTS': '0', 'REINSTALL_PY_PACKAGE': '0'},
)