When you deploy an app on Enclave, you can define one or multiple services.
Services represent isolated components of your app that use the same source code and configuration, but run different commands, such as a web service and background job processor.
Services run in separate containers, and can be scaled independently.
Services for an app must be defined in one of two ways:
- If your app has a git repository and contains a file named
Procfilein the root of the repository , the Procfile will be used to define services.
- Otherwise, if your app has a
CMDin its Docker image (or Dockerfile), the
CMDwill be used to define a single service.
If your app has no Procfile nor
CMD, Enclave will not be able to deploy it.
If you are using a Procfile, it must contain one or more lines with the following format:
1 process_type: command [arguments...]
Here are some examples.
One process (Rails server)
1 web: bundle exec rails server
Two processes (Rails server and Sidekiq background processor):
1 2 web: bundle exec rails server worker: bundle exec rake jobs:work
The Procfile command is interpreted using a shell, so you can use shell syntax there. For example:
1 web: bundle exec rails server -p $PORT
Multiple services vs. multiple apps
When you use multiple services, they will all share the following:
- All services of an app use the same Docker Image.
- All services of an app use the same configuration.
- All services of an app are deployed at the same time.
In other words, multiple services make your life a little simpler when you need to release new code (i.e. a new Docker Image) or new configuration: you do it once, and it applies to all services.
However, there’s nothing you can do with multiple services that cannot be done with multiple apps, so if you need additional flexibility (e.g. use different code for different services, or use different configuration), then you can always use multiple apps with one service each.