Check the lab
folder to explore the various elements of the deployment more easily.
One needs to create an .env
file with the following keys:
Note: add a copy to both
05_pre_processing_build
(to build the docker images and run the docker-compose locally) and06_pre_processing_deploy/terraform
(to run the docker compose remotly)
One also needs to get .PEM files to allow Terraform to upload the script that will be executed to install and run the initial docker image.
PREFECT Flows
and PREFECT Agent
imagesNote: one needs to replace
valkea
with its own docker-hub profile.
PREFECT Flows
container and push it.>>> docker build -t ungdc_prefect_flows . -f Dockerfile.flows
>>> docker tag ungdc_prefect_flows:latest valkea/ungdc_prefect_flows:latest
>>> docker push valkea/ungdc_prefect_flows:latest
PREFECT Agent
container and push it.>>> docker build -t ungdc_prefect_agent . -f Dockerfile.agent
>>> docker tag ungdc_prefect_agent:latest valkea/ungdc_prefect_agent:latest
>>> docker push valkea/ungdc_prefect_flows:latest
Note: We could improve this with a GitHub Action or CirlceCI CI/CD to automatically build and push the containers on the docker hub or on the AWS ECS.
In order to be able to control the deployed PREFECT Agent
, we need to register the PREFECT blocks and the deployment on the PREFECT Cloud server.
Edit config.cfg
and update the various fields.
>>> make setup
In order to test and run the Prefect pre-processing locally, one can use the following commands:
>>> cd {to the directory with the docker-compose.yaml file. Currently 05_pre_processing_build}
>>> docker compose up
One can check that the Weaviate instance is running by checking localhost with port 8080. That's a good indicator that the stack is ready.
On the Prefect pipeline is running, you can test it by waiting the the cronjob and by triggering the Deployment on the Prefect Cloud.
Deployment
and click ...
Custom run
of the deployment with max_doc
= 1Flow runs
and explore (the first run might take time, because it needs to download the 5Gb docker image of the Pre-processing pipeline)Let's use Terraform the provision the ressources and deploy our PREFECT Agent
Generate AWS .PEM files (from the AWS website) and place them (.pem and .pem.pub) in the terraform folder.
Edit terraform/variables.tf
and update the various fields.
Use the following commands from inside the terraform folder, to see the plan and apply the plan:
>>> terraform plan
>>> terraform apply
Once started, the EC2 instance will execute the config_docker.sh
file and run the PREFECT Agent
container which will in turn pull and run the PREFECT Flows
container whenever requested through the PREFECT Cloud interface (or via command lines).
At this point you can use instructions from 4.1 and 4.2 to test the deployment.
The terraform apply
command should have displayed the current external IP of the EC2 instance (and links to directly access the Weaviate API). It this is not the case, just use terraform apply
a second time (in some case the EC2 is not ready yet and can't return the external IP)
To shut down the deployment, one can use the following command (from inside the terraform folder):
>>> terraform destroy