Deploying multiple dockerfiles

We currently are deploying a single web server, but we are looking to move to having a web server plus a worker that handles scheduled tasks and queue-related items. I believe our Procfile will look like this example: Procfiles

In that situation, would we still just have a single dockerfile that sets up everything for both the server and the worker service? If we wanted to have two dockerfiles would we need to use Direct Docker Image Deployment? Or is it not even possible?

The Services vs Apps documentation kind of touches on this but doesn’t provide specifics on when to choose one or the other.

Each Aptible App has a single Docker Image associated with it. Each of the App’s Services uses the same image but runs a different command as defined in the Procfile. So, in order to deploy multiple images, you need to use multiple Apps.

The general rule of thumb is, if the two of your services use the same codebase, then deploying them as a single App with multiple Services is generally beneficial since they’ll be deployed together. Workers that leverage the same codebase as the corresponding web application such as Rails + Sidekiq or Django + celery are good examples of when to use a single App.

If the services use different codebases or you find that you’re putting in a lot of effort to make both services work with the same Dockerfile, then deploying them as separate Aptible Apps would likely be easier. Separate Apps are commonly used when deploying frontend and backend applications using different frameworks such as React, Angular, or Vue on the frontend and Rails or Django for the backend.

You can also think of it as one App per git repo. If you find it difficult to build a single Docker image that encompasses all of the services in your git repo, the repo should likely be split and multiple Apps used. Vice versa, if you find you’re duplicating a lot of code between git repos then they should probably be merged into a single repo and deployed as a single App. While the structure of repositories applies directly to Dockerfile Deployment, it’s a good guide for how to structure projects when using Direct Docker Image Deployment as well.