Services
Services are containers that are triggered by an HTTP endpoint. Examples of services include:
- Websites
- APIs
- Webhooks
For these endpoints, we use our scale-to-zero technology to shut down unused resources and initialize them only when a request comes in.
How it Works
When you create a service, we create a public endpoint and issue a valid TLS certificate for it. By default, this endpoint hosts an empty HTTP server that you can use to test your setup.
When you provide us with a container image, we replace our static placeholder with your website or API.
Container Image Requirements
Each container image is initialized on demand, so any system deployed to DownToZero (DTZ) needs to be designed with this in mind.
By default, DTZ sets a PORT
environment variable for the container and expects the instance to be launched on that port. If your application needs to run on a specific port, you can override this variable.
To check the availability of your deployed application on startup, the runtime calls the port with a HEAD /
request. If the response is not an error, the load balancer marks the backend as running.
Environment Variables
The runtime provides the following environment variables to your service:
variable | settable | description |
---|---|---|
PORT | yes | The port your application should listen on. |
DTZ_ACCESS_TOKEN | yes (identity can be changed) | A JWT generated from the context that allows resources to be accessed within the context. |
DTZ_CONTEXT_ID | no | The DTZ context that the current application is running in. |