<@ULVA73B9P> Is it normal to use a separate Docker...
# marvin-in-the-wild
m
@Marvin Is it normal to use a separate Dockerfile for each flow? Context being, I have a Dockerfile, that ideally I'd like to re-use for each flow and just modify the
CMD
for each flow, rather than building a separate image for each, where only
CMD
changes. What is the recommended way of handling Docker images across multiple flows?
m
The recommended way of handling Docker images across multiple Prefect flows seems to favor building a shared custom image if your flows require extra dependencies or shared libraries. This single image can contain all the necessary dependencies and shared task definitions. You would then use this shared image for multiple flows, which could be more efficient than building a separate image for each flow, especially when the differences between them are minor such as a change in the
CMD
. Here are the key takeaways: - Docker-based Storage: This method stores your flow code in a Docker image. Changes to the code have to be pushed manually or through a CI/CD pipeline. - Custom Images for Complex Dependencies: If your flows require complicated installations or shared libraries, it's best to create a common custom image. - Reusable Images: You can build a shared custom image for use with multiple flows. For your situation, if the only change between flows is the
CMD
, utilizing a shared Dockerfile and image makes sense. You should consider parametrizing your Dockerfile or entrypoint script to accept arguments or environment variables that change the command or flow being executed. Refer to these resources for more information: - Docker-based storage - Using Docker with Prefect Try including your flows in a single image, parameterizing the entry point, and specifying the flow to run based on the environment variable or command-line argument passed to the container. This approach should maintain the simplicity of your CI/CD pipeline while reducing the overhead of maintaining multiple nearly identical Docker images.