Skip to main content

Deployment

Requirements​

Deploying on Lagoon?​

Add the token as an environment variable through the Lagoon dashboard by following the steps below:

Adding the token as a project variable​

  1. Navigate to the Lagoon dashboard and choose the desired project where you wish to add the variable.
  2. Click on the Variables tab on the sidebar.
  3. Click on the Add button.
  4. Fill in the details as follows:
Variable Configuration
  • Scope: Build
  • Name: GITLAB_API_TOKEN
  • Value: The token value which you've previously generated.
  1. Click on the Add project variable button to add the variable.
  2. Trigger a redeployment of your project environments to apply the changes and ensure the variable becomes available.

Referencing the token in the docker file​

Once the token is added as a project variable, it can be referenced in your docker file (eg. ./lagoon/cli.dockerfile) as shown below:

Frontend project example:​
ARG GITLAB_API_TOKEN
RUN echo "@acromedia:registry=https://git.acromedia.com/api/v4/packages/npm/" >> .npmrc
RUN echo "//git.acromedia.com/api/v4/packages/npm/:_authToken=${GITLAB_API_TOKEN}" >> .npmrc
RUN echo "//git.acromedia.com/api/v4/projects/:_authToken=${GITLAB_API_TOKEN}" >> .npmrc
Drupal project example:​
ARG GITLAB_API_TOKEN
RUN if [[ -n "${GITLAB_API_TOKEN}" ]] ; then \
composer config gitlab-token.git.acromedia.com ${GITLAB_API_TOKEN}; \
fi

Health check​

Projects generated with create-gesso or create-nextjs serve a health check at /api/health. It answers 200 OK from the Next.js server alone and never calls the CMS or the commerce backend.

Point your platform's health check (load balancer, Kubernetes probe, rollout check) at /api/health and not at the home page. The home page needs backend content, so a backend outage would make a healthy frontend look down and could roll back a deploy.

The route answers GET and HEAD requests, and its response is never cached.

Adding it to an existing project​

A project generated before this route existed can add it by hand.

App Router: src/app/api/health/route.ts​
export function GET() {
return new Response('OK', {
status: 200,
headers: { 'Cache-Control': 'no-store' },
});
}
Pages Router: src/pages/api/health.ts​
import type { NextApiRequest, NextApiResponse } from 'next';

export default function handler(
request: NextApiRequest,
response: NextApiResponse,
) {
if (request.method !== 'GET' && request.method !== 'HEAD') {
response.setHeader('Allow', 'GET, HEAD');
response.status(405).end();
return;
}

response.setHeader('Cache-Control', 'no-store');
response.setHeader('Content-Type', 'text/plain; charset=utf-8');
response.status(200).send('OK');
}