Skip to main content

Stack key and layout

Stack key​

The key identifies a stack. It is derived from the verified token, never from the request:

<key> = slug(project_path) + "-" + slug(environment)

The slug reproduces GitLab's CI_PROJECT_PATH_SLUG: lowercase, every character other than a-z and 0-9 becomes -, leading and trailing hyphens trimmed, truncated to 63 bytes. Consecutive hyphens are not collapsed.

project_pathenvironmentKey
group/appstaginggroup-app-staging
Apps/Atmosphere/Shopproductionapps-atmosphere-shop-production
acme-shop/apistagingacme-shop-api-staging
acme/shop-apistagingacme-shop-api-staging (collision)

environment is the environment name. For simple names (letters and digits, at most 24 characters, starting with a letter) the slug equals CI_ENVIRONMENT_SLUG. For other names GitLab adds a hash suffix to CI_ENVIRONMENT_SLUG and the slugs differ.

Every compose command is pinned to the key: docker compose -p <key> --project-directory COMPOSE_BASE/<key> -f COMPOSE_BASE/<key>/docker-compose.yml.

Ownership​

EndpointUnclaimed keyKey of the caller's project_idKey of another project
POST /deployAllowed, claimed after a successful upAllowed403
POST /directoriesAllowed, stays unclaimedAllowed403
POST /exec403Allowed403
DELETE /stack403Allowed, ownership released403

The registry also stores the exact project_path and environment of each key. A different project reaching the same key with a different tuple gets a distinct 403 and a registry: key collision between distinct deployments warning in the log. An auto-stop keeps the ownership.

On-disk layout​

PathContentRemoved by
DATA_DIR/registry.jsonOwnership of each keyNever (entries released by DELETE /stack)
DATA_DIR/autostop.jsonPending auto-stops, keyed <namespace>/<environment>Never (entries removed when done or cancelled)
COMPOSE_BASE/<key>/docker-compose.yml and the uploaded env filesDELETE /stack, auto-stop
COMPOSE_BASE/.staging-<key>-*A deploy being validatedThe deploy itself
WEBSITES_BASE/<key>/<service>/<name>/Application data (bind mounts)Never

State files are written atomically (temporary file, rename, directory fsync).

registry.json​

Also the format of the -import-registry file. A JSON object keyed by stack key; each value is an entry object or a bare project_id string.

{
"group-app-staging": {
"project_id": "42",
"project_path": "group/app",
"environment": "staging"
},
"other-production": "7"
}
FieldRequiredDescription
project_idyesGitLab project ID owning the key
project_pathnoExact project path; enables collision detection
environmentnoExact environment name; enables collision detection
claimed_atnoDefaults to the import time

On import, a key already owned by a different project_id aborts the whole import. A key owned by the same project_id is kept and its missing fields are filled in.