Pre-deploy Job
Configure a pre-deploy job to run essential tasks that must be completed before application deployments, such as database migrations or seedings.
A pre-deploy job runs as a pod before your application is deployed. If the pre-deploy job fails, the application deployment is aborted.
Adding a Pre-deploy Job Container
- In the Application Overview tab, click the three-dot menu in the top-right corner and select "Add pre-deploy job."
- Configure the pre-deploy job container:
- Container registry: Select the container registry connection. Learn more about container registry connection here.
- Image repository: Select the desired image repository.
- Image tag: Select the image tag.
- Click "Confirm" to add the container. You will be redirected to the pre-deploy job tab to add environment variables required by the container.
- Whenever you deploy the application, the pre-deploy job will run first.
note
Best Practices for Pre-Deploy Job Containers
- Ephemeral: The job should be ephemeral. Job will be terminated if it runs for more than 8 minutes.
- Image Size: Use lightweight base images and minimize dependencies to reduce the attack surface and improve startup time.
- Idempotency: Ensure the job can be safely run multiple times without causing unintended side effects.
- Environment Configuration: It is advisable to use environment variables as inputs to your pre-deploy job instead of command line arguments in the startup command
- Logging: Implement comprehensive logging to capture job execution details for debugging in case of failures.