PHP Deploy process
Application artefact​
When the build phase is finished, the application artefact is stored in the internal Zerops storage and the build container is deleted.
If you triggered the deploy pipeline manually using Zerops CLI, the application artefact is also uploaded to the internal Zerops storage.
Zerops uses the stored artefact to deploy the identical version of your application each time a new container is started:
- when a new application version is deployed
- when the application scales horizontally
- when a runtime container fails and a new container is started automatically
First deploy​
When your application is deployed for the first time, Zerops will start one or more runtime containers based on the service auto scaling settings.
Zerops performs following actions for each new container:
- Installs the runtime environment
- Downloads the application artefact from the internal storage
- Optionally runs the init commands
- Starts your application
- Optionally waits until the readiness check succeeds
- The container is now active and receives incoming requests.
Services with multiple containers are deployed in parallel.
If your application needs to be initialized in each runtime container, add init commands to zerops.yml
.
Do not use the initCommands
for customising your runtime environment. See how to customize the runtime environment.
Further deploys​
When a previous version of your application is already running, Zerops will start new containers. The count of new containers will be the same as the count of existing containers.
Zerops performs the identical actions for each new container as the first deployment. When all new containers are started your service contains both new and old versions for a short period of time.
The old containers are then removed from the project balancer so they don't receive new requests. The PHP process inside each of the old containers is terminated and all old containers are gradually deleted.
Readiness checks​
If your application isn't ready as soon as it starts, configure a readiness check in your zerops.yml
.
If the readiness check is defined, Zerops will:
- Start your application
- Perform a readiness check
- If the readiness check fails, wait 5 seconds and repeat step 2.
- If the readiness check succeeds, set the container as active.
Application in the runtime container with a pending readiness check won't receive any incoming requests. Only active containers receive incoming requests to your PHP service.
If the readiness check is still failing after 5 minutes, the specific runtime container is marked as failed and Zerops will delete it, create a new runtime container and perform the deploy.
The httpGet
readiness check is successful when the URL returns HTTP status code 2xx
. The timeout is 5 seconds. When the URL returns a 3xx
HTTP status, the readiness check HTTP client will follow the redirect.
The exec.command
readiness check is successful when the command returns status code 0. The timeout is 5 seconds.
Read the runtime log to troubleshoot failed readiness checks.
Application versions​
Zerops keeps 10 last versions of your application in the internal storage.
The list of application versions is available in Zerops GUI. Go to the service detail and choose Service dashboard & runtime containers from the left menu. The active version is highlighted, show all archived version by clicking on the button below.
The pipeline detail is accessible from the additional menu. The pipeline detail contains
- The pipeline config (
zerops.yml
) that was used for the selected version - The build log (if available)
- The prepare runtime log (if available)
You can download the build artefact of the selected version or delete an inactive version manually.
Restore an archived version​
You can restore an archived version by choosing the Activate item from the additional menu. Zerops will deploy the selected version and the active version will be archived.
The environment variables will be restored to the latest moment when the selected version was active.