This directory contains annotated files for deploying Dagster with an EcsRunLauncher to AWS ECS using Docker Compose. You can use these as a reference for configuring your own Dagster ECS deployment.
- Install Docker
- Create an AWS account
- Install the AWS CLI
- Configure IAM permissions
- Create a Docker ECS context:
docker context create ecs dagster-ecs
- Create ECR Repositories for our images:
aws ecr create-repository --repository-name deploy_ecs/dagit
aws ecr create-repository --repository-name deploy_ecs/daemon
aws ecr create-repository --repository-name deploy_ecs/user_code
- Log in to your ECR Registry (ensure that the $AWS_REGION environment variable is set to your registry's AWS region):
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --output text | cut -f1)
export REGISTRY_URL=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $REGISTRY_URL
Our docker-compose.yaml builds all of its images from local multi-stage Dockerfile. To expose these images to ECS, we first need to build them and then push them to the ECR Repositories we created:
docker compose build
docker compose push
docker --context dagster-ecs compose --project-name dagster up
The first time you run this command, Docker will provision the necessary resources to run your stack on ECS. --context dagster-ecs
tells Docker to run the containers on the Docker ECS context that we created. --project-name dagster
tells Docker how to name the stack.
One of the resources Docker creates is an AWS ELB Load Balancer. You can access Dagit on port 3000 of the Load Balancer's URL. To find the Load Balancer's URL, look for the Load Balancer tagged with our project name.
Subsequent runs of this command will execute a rolling update of the stack.
Once you're done experimenting with this reference deployment, you should destroy the AWS resources it creates.
docker --context dagster-ecs compose --project-name dagster down
This will stop your running services and tear down any infrastructure Docker provisioned on your behalf.