Fugo Takefusa
09/24/2025, 5:08 AMMarvin
09/24/2025, 5:08 AMMarvin
09/24/2025, 5:15 AM# Start from a slim Python base
FROM python:3.11-slim
# Install Prefect and AWS extras (if your flow uses AWS libs)
ENV PIP_NO_CACHE_DIR=1
RUN pip install --upgrade pip \
&& pip install "prefect>=3,<4" "prefect-aws" # or: pip install 'prefect[aws]'
# Optionally: install your project requirements
# COPY requirements.txt .
# RUN pip install -r requirements.txt
# Optionally: add your code if you bake flows into the image
# COPY . /opt/project
# ENV PYTHONPATH=/opt/project
Where to set the image:
- Default for the pool: In your ECS work pool’s base job template (UI or API), set the container definition’s image
to your ECR/Docker image.
- Per deployment: Provide an image when deploying your flow so each deployment can pin its own runtime image. In code this typically looks like:
from prefect import flow
@flow
def my_flow():
...
if __name__ == "__main__":
(
my_flow
.from_source("<https://github.com/your-org/your-repo>", "path/to/flow.py:my_flow")
.deploy(
name="prod",
work_pool_name="my-ecs-pool",
image="<http://123456789012.dkr.ecr.us-east-1.amazonaws.com/myflow:2025-09-24|123456789012.dkr.ecr.us-east-1.amazonaws.com/myflow:2025-09-24>"
)
)
Recommendations and notes:
- Prefer pinning a specific tag (not latest
) to make runs reproducible.
- Make sure your ECS cluster/role can pull the image (ECR permissions).
- If you interact with AWS services from the flow, include the needed libs (boto3, s3fs, etc.).
- The worker image and the flow-run image are separate — the worker only launches ECS tasks; your flow code runs inside the image you specify above.
Docs to dig deeper:
- Prefect AWS ECS guide
- How to store and ship flow code in deployments
If you share your Python version and any heavy dependencies, I can sketch a Dockerfile tailored to your stack.