Billy McMonagle
03/04/2021, 2:34 PMS3Storage
and KubernetesRun
. Thanks in advance for any guidance.Billy McMonagle
03/04/2021, 2:38 PMextract_flow_from_file
utility function, but add a hook of some kind to remove the import
statements. Haven't tried this. Seems like it should work, but also feels like a hack.
(3) Put the flow registration commands in the Dockerfile for each flow.Jim Crist-Harif
03/04/2021, 2:53 PMSean Talia
03/04/2021, 2:55 PMdocker-compose.yml
that looks like this:
example_flow:
image: <EXAMPLE_FLOW_DOCKER_RUN_CONFIG_IMAGE>:latest
volumes:
- "./flows/example_flow/flow.py:/app/flow.py"
- "./register_flow.sh:/app/register_flow.sh"
command: "./register_flow.sh"
my github action is looking for changes in the flows/example_flow/
path (i.e. where the flow code is hosted), and when it sees one, it pulls this compose service and then runs it. I use GitHub secrets in my workflow step to pass my cloud token as an environment variable into the container, and then it's all good to goBilly McMonagle
03/04/2021, 2:57 PMSean Talia
03/04/2021, 2:57 PMBilly McMonagle
03/04/2021, 2:57 PMSean Talia
03/04/2021, 2:58 PMregister_flow.sh
script is incredibly lightweight, all it does is prefect auth login --token $PREFECT_TENANT_TOKEN
and then calls the python script that registers the flowBilly McMonagle
03/04/2021, 2:59 PMBilly McMonagle
03/04/2021, 2:59 PMSean Talia
03/04/2021, 3:02 PMactions/checkout@v2
action, so this makes it incredibly easy because it's actually just checking out my entire repository onto the host that's been provisioned to run the GA workflowBilly McMonagle
03/04/2021, 3:04 PMSean Talia
03/04/2021, 3:04 PMregister_flow.sh
script, and my docker-compose.yml
all available on the machine, and that's all that's neededBilly McMonagle
03/04/2021, 3:05 PMSean Talia
03/04/2021, 3:05 PMSean Talia
03/04/2021, 3:06 PMSean Talia
03/04/2021, 3:07 PMBilly McMonagle
03/04/2021, 3:07 PMBilly McMonagle
03/04/2021, 3:07 PMSean Talia
03/04/2021, 3:08 PMBilly McMonagle
03/04/2021, 3:08 PMJim Crist-Harif
03/04/2021, 3:11 PMSean Talia
03/04/2021, 3:17 PMSean Talia
03/04/2021, 3:17 PMSean Talia
03/04/2021, 3:19 PMJim Crist-Harif
03/04/2021, 3:20 PMBilly McMonagle
03/04/2021, 3:22 PMSean Talia
03/04/2021, 3:23 PMBilly McMonagle
03/04/2021, 3:24 PMSean Talia
03/04/2021, 3:28 PMSean Talia
03/04/2021, 3:29 PMBilly McMonagle
03/04/2021, 3:31 PMBilly McMonagle
03/04/2021, 3:32 PMBilly McMonagle
03/04/2021, 3:32 PMSean Talia
03/04/2021, 3:33 PMSean Talia
03/04/2021, 3:34 PMSean Talia
03/04/2021, 3:34 PMBilly McMonagle
03/04/2021, 3:37 PMAdam
03/04/2021, 5:16 PMBilly McMonagle
03/04/2021, 5:35 PMHawkar Mahmod
04/13/2021, 2:36 PMBilly McMonagle
04/14/2021, 2:48 PMHawkar Mahmod
04/14/2021, 2:50 PMBilly McMonagle
04/14/2021, 2:50 PMBilly McMonagle
04/14/2021, 2:53 PM# list all flows here
FLOWS := \
flow1
flow2
etc
build/%:
@echo "building flows/${@F}"
REPO=${REGISTRY}/${APP}/${@F} && \
docker build --file flows/${@F}/Dockerfile . \
--cache-from $$REPO:${GIT_SHA} \
--cache-from $$REPO:${GIT_BRANCH} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg APP=${APP} \
--build-arg AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} \
--build-arg AWS_REGION=${AWS_REGION} \
--build-arg BUCKET_NAME=${BUCKET_NAME} \
--build-arg FLOW_NAME=${@F} \
--build-arg GIT_BRANCH=${GIT_BRANCH} \
--build-arg GIT_SHA=${GIT_SHA} \
--build-arg HELM_CHART=${HELM_CHART} \
--build-arg HELM_RELEASE=${HELM_RELEASE} \
--build-arg PREFECT_VERSION=${PREFECT_VERSION} \
--build-arg PYTHON_RUNTIME=${PYTHON_RUNTIME} \
--build-arg SSM_ENV=${SSM_ENV} \
--secret id=prefect_token,src=prefect_token
--tag $$REPO:${GIT_SHA} \
--tag $$REPO:${GIT_BRANCH}
push/%:
docker push "${REGISTRY}/${APP}/${@F}:${GIT_SHA}"
docker push "${REGISTRY}/${APP}/${@F}:${GIT_BRANCH}"
## run targets for all flows
all: build push
build: $(foreach flow,${FLOWS},build/${flow})
push: $(foreach flow,${FLOWS},push/${flow})
.PHONY: all build push
Billy McMonagle
04/14/2021, 2:55 PMBUILDKIT_INLINE_CACHE=1
and use the --cache-from
argument pointed at your remote ECR repository and get some good results.Hawkar Mahmod
04/14/2021, 2:59 PMBilly McMonagle
04/14/2021, 3:00 PMHawkar Mahmod
04/15/2021, 7:52 AMregister
call. But that does leave me a bit puzzled with the choice of Storage. Having read this thread and others there seems to be a recommendation to move away from the use of Docker Storage in favour of GitHub or S3. I chose to move to S3 Storage because I saw that the registration time was drastically reduced. However this deployment procedure you’ve used loses some of that benefit because you have to rebuild this image upon each deployment. The only reasons I think of to prefer S3 Storage over Docker Storage now are:
a) Flexibility to change and put live flow code without a full deployment. You can just call register
locally and have the Docker image from the existing deployment be used as your execution environment.
b) To avoid the Docker-in-Docker scenario that would require you to build a Docker image, only to build another one upon calling register
with Docker
Storage.