GitLab CI
Compose
Example

GitLab CI Compose Example

Create a Docker Compose environment from a GitLab CI pipleine.

Fork the quickstart repository

Start by forking the the quickstart (opens in a new tab) repository on GitLab. From the project home page, select Fork, then choose a namespace and project slug. Select Fork project.


Fork quickstart repo
Select fork

Enable CI/CD

Ensure GitLab CI/CD is enabled for your project. If you don't see the **Build > Pipelines** option in left sidebar, following these steps (opens in a new tab) to enable it.


Enable CI/CD

Open a Merge Request

Open a merge request (MR) for try-uffizzi branch against master in your fork.

⚠️

Be sure that you’re opening the MR on the branches of your fork (i.e. your-account/masteryour-account/try-uffizzi).

If you try to open a MR for uffizzi/quickstart/~/tree/masteryour-account/~/tree/try-uffizzi, the pipeline will not run in this example.


Open a merge request

This will kick off a GitLab pipeline and the ephemeral environment URL will be dumped to stdout of the pipeline job.

What to expect

The MR will trigger a pipeline defined in .gitlab-ci.yml (opens in a new tab) that creates a Uffizzi ephemeral environment for the microservices application defined by the repo. The ephemeral environment URL will be echoed to stdout of the deploy_environment Job. Look for the following line in the Job logs:

$ echo "Uffizzi Environment deployment details at URI:${UFFIZZI_CONTAINERS_URI}"
Uffizzi Environment deployment details at URI:https://app.uffizzi.com//projects/8526/deployments/27720/containers

This link will take you to the Uffizzi Dashboard where you can view application logs and manage your environments and team. The environment will be deleted when the MR is merged/closed or after 1 hour (configurable (opens in a new tab)).

You might also want to configure a new Job to post the URL as a comment to your MR issue or send a notification to Slack, MS Teams, etc. See our Slack notification example here (opens in a new tab).

How it works

Ephemeral environments are configured with a Docker Compose template (opens in a new tab) that describes the application components and a GitLab CI pipeline (opens in a new tab) that includes a series of jobs triggered by a merge_request_event:

  1. Build and push images to a container registry (opens in a new tab)
  2. Render a Docker Compose file from the Docker Compose template and the built images (opens in a new tab)
  3. Deploy the application to a Uffizzi ephemeral environment and echo the environment URL to the Job logs (opens in a new tab)
  4. Delete the environment (opens in a new tab)
💡

Each ephemeral environment is available at a predictable URL which consists of https://app.uffizzi.com/ appended with the GitLab merge request domain. For example:
https://app.uffizzi.com/gitlab.com/{account}/{repo}/merge_requests/{merge-request-number}.

You can make requests to specific endpoints by appending a route to the end of the URL. For example:
https://app.uffizzi.com/gitlab.com/acme/example-app/pull/661/api/health

Running this workflow will create a Uffizzi Cloud (opens in a new tab) account and project from your GitLab user and repo information, respectively. If you sign in to the Uffizzi Dashboard (opens in a new tab) you can view logs, password protect your environments, manage projects and team members, set role-based access controls, and configure single-sign on (SSO).