From 558d9dfb9c7ffaea6fb01d8be180b9c557e846be Mon Sep 17 00:00:00 2001 From: kylegalbraith Date: Fri, 17 Nov 2023 11:46:32 +0100 Subject: [PATCH] be explicit about project tokens --- content/integrations/gitlab-ci.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/content/integrations/gitlab-ci.mdx b/content/integrations/gitlab-ci.mdx index 41a76ac..692c07d 100644 --- a/content/integrations/gitlab-ci.mdx +++ b/content/integrations/gitlab-ci.mdx @@ -20,7 +20,7 @@ It is also possible to generate a user access token that can be injected into yo ## Configuration -To build a Docker image from GitLab, you must set the `DEPOT_TOKEN` environment variable in your CI/CD settings for your repository. You can do this through the UI for your repository via [this documentation](https://docs.gitlab.com/ee/ci/variables/index.html). +To build a Docker image from GitLab, you must set the `DEPOT_TOKEN` environment variable in your CI/CD settings for your repository. You can do this through the UI for your repository via [this documentation](https://docs.gitlab.com/ee/ci/variables/index.html). We recommend using a [project token](/docs/cli/authentication#project-tokens). In addition, you must also install the `depot` CLI before you run `depot build`. @@ -31,6 +31,7 @@ build-image: script: - depot build . variables: + # Pass project token or user access token DEPOT_TOKEN: $DEPOT_TOKEN ``` @@ -48,7 +49,7 @@ You then inject that file before the build, which allows `depot build . --push` **Note:** This requires configuring an additional CI/CD variable, but it avoids using Docker-in-Docker. -```yaml +```yaml showLineNumbers build-image: before_script: - curl https://depot.dev/install-cli.sh | DEPOT_INSTALL_DIR=/usr/local/bin sh @@ -57,6 +58,7 @@ build-image: script: - depot build -t registry.gitlab.com/repo/image:tag . --push variables: + # Pass project token or user access token DEPOT_TOKEN: $DEPOT_TOKEN ``` @@ -64,7 +66,7 @@ build-image: This example demonstrates using the [Docker-in-Docker](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor) executor. This method allows you to install the `depot` CLI in the `before_script` block and use `docker login` to authenticate to whichever registry you use. -```yaml +```yaml showLineNumbers image: docker:20.10.16 services: - docker:20.10.16-dind @@ -80,5 +82,6 @@ build-image: - echo "$DOCKER_REGISTRY_PASS" | docker login registry.gitlab.com --username --password-stdin - depot build --project -t registry.gitlab.com/repo/image:tag . --push variables: + # Pass project token or user access token DEPOT_TOKEN: $DEPOT_TOKEN ```