https://prefect.io logo
m

Mattias Petter Johansson

09/12/2023, 2:38 PM
@Marvin how can I deploy a newly built docker container that I have just pushed to amazon ecr (199214789681.dkr.ecr.eu-north-1.amazonaws.com/data-science:latest) using docker deployment build?
m

Marvin

09/12/2023, 2:38 PM
Oh, the joys of human tasks. So, you've built a Docker container and pushed it to Amazon ECR, and now you want to deploy it. Well, aren't we ambitious today? Here's a general outline of the steps you might take: 1. First, you'll need to install the AWS CLI and Docker on your machine, if you haven't already. But I suppose you've done that already, haven't you? 2. Next, you'll need to authenticate Docker to your Amazon ECR registry. You can do this by running the
aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin <http://199214789681.dkr.ecr.eu-north-1.amazonaws.com|199214789681.dkr.ecr.eu-north-1.amazonaws.com>
. This command retrieves an authentication token and authenticates your Docker client to your registry. 3. Now that Docker is authenticated, you can deploy your Docker container. If you're just running it on your local machine, you can use the
docker run
command, like so:
docker run -p 8000:8000 <http://199214789681.dkr.ecr.eu-north-1.amazonaws.com/data-science:latest|199214789681.dkr.ecr.eu-north-1.amazonaws.com/data-science:latest>
. This command tells Docker to run your container and map port 8000 on your machine to port 8000 on the container. 4. If you're deploying to a service like Amazon ECS, you'll need to create a new task definition with your ECR image and update your service to use the new task definition. Remember, these are just general steps. The specifics might vary depending on your setup. But then again, I'm just a robot. What do I know about human error and its propensity for complicating things?
m

Mattias Petter Johansson

09/12/2023, 2:40 PM
how can I create a new task defintion for docker using the prefect_aws python library, and then use that in prefect deploument build?
m

Mattias Petter Johansson

09/12/2023, 2:55 PM
@Nate I know about that guide, but thanks! What is confusing me is that I am trying to use the tf-prefect2-ecs-agent terraform, and one thing that stumps me is that is allows you to specify an agent_image but not a task image. As I understand the architecture, the agent isn’t really the thing the workflows, and doesn’t really need a custom image and can just use prefecthq/prefect:2-python3.9. For the deployments themselves (of which will be run in en ECS Task, will need to run in a custom docker container stored in our AWS ECR, and I am confused as to where this should be defined if one if one is using this terraform recipe. I am currently exploring extracting the terraform.tfstate output from terraform and creating an ECSTask with prefect_aws based on those values. From what I gather, the recipe only generates the worker ECS service, and I need to create the ECS task myself in this fashion. Is this a correct understanding of the recipe usage and a sensible approach you think, or am I misunderstanding something?
n

Nate

09/12/2023, 3:41 PM
if you dont mind, why are you using agents instead of workers?