InfoGrab Docs

Google Artifact Management

요약

Google Artifact Management 통합을 사용하여 Google Artifact Registry 저장소를 GitLab 프로젝트에 구성하고 연결할 수 있습니다. Google Artifact Registry를 프로젝트에 연결한 후 Google Artifact Registry 저장소에서 Docker 및 OCI 이미지를 보고, 푸시하고, 가져올 수 있습니다.

히스토리

Google Artifact Management 통합을 사용하여 Google Artifact Registry 저장소를 GitLab 프로젝트에 구성하고 연결할 수 있습니다.

Google Artifact Registry를 프로젝트에 연결한 후 Google Artifact Registry 저장소에서 Docker 및 OCI 이미지를 보고, 푸시하고, 가져올 수 있습니다.

GitLab 프로젝트에서 Google Artifact Registry 설정#

사전 요구 사항:

  • GitLab 프로젝트에 대한 유지 관리자 또는 소유자 역할이 있어야 합니다.
  • Artifact Registry 저장소가 있는 Google Cloud 프로젝트에 대한 액세스를 관리하는 데 필요한 권한이 있어야 합니다.
  • Google Cloud에 인증하기 위해 워크로드 아이덴티티 페더레이션 (WLIF) 풀과 공급자가 구성되어 있어야 합니다.
  • 다음 구성의 Google Artifact Registry 저장소:
    • Docker 형식.
    • 표준 모드. 다른 저장소 형식과 모드는 지원되지 않습니다.

Google Artifact Registry 저장소를 GitLab 프로젝트에 연결하려면:

  1. 상단 바에서 검색 또는 이동을 선택하고 프로젝트를 찾습니다.
  2. 왼쪽 사이드바에서 설정 > 통합을 선택합니다.
  3. Google Artifact Management를 선택합니다.
  4. 통합 활성화에서 활성 체크박스를 선택합니다.
  5. 필드를 입력합니다:
  6. 화면의 지시에 따라 Google Cloud Identity and Access Management (IAM) 정책을 설정합니다. 정책 유형에 대한 자세한 내용은 IAM 정책을 참조하세요.
  7. 변경 사항 저장을 선택합니다.

이제 사이드바의 배포 아래에 Google Artifact Registry 항목이 표시됩니다.

Google Artifact Registry에 저장된 이미지 보기#

사전 요구 사항:

  • 프로젝트에 Google Artifact Registry가 구성되어 있어야 합니다.

GitLab UI에서 연결된 Artifact Registry 저장소의 이미지 목록을 보려면:

  1. 상단 바에서 검색 또는 이동을 선택하고 프로젝트를 찾습니다.
  2. 왼쪽 사이드바에서 배포 > Google Artifact Registry를 선택합니다.
  3. 이미지 세부 정보를 보려면 이미지를 선택합니다.
  4. Google Cloud 콘솔에서 이미지를 보려면 Google Cloud에서 열기를 선택합니다. 해당 Artifact Registry 저장소를 보려면 필요한 권한이 있어야 합니다.

CI/CD#

사전 정의 변수#

Artifact Registry 통합이 활성화되면 다음 사전 정의 환경 변수를 CI/CD에서 사용할 수 있습니다. 이러한 환경 변수를 사용하여 연결된 저장소에서 이미지를 가져오거나 푸시하는 등 Artifact Registry와 상호 작용할 수 있습니다.

Variable GitLab Runner Description
GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID 16.10 16.10 Artifact Registry 저장소가 위치한 Google Cloud 프로젝트 ID.
GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME 16.10 16.10 연결된 Artifact Registry 저장소의 이름.
GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION 16.10 16.10 연결된 Artifact Registry 저장소의 Google Cloud 위치.

Google Artifact Registry 인증#

파이프라인 실행 중 Google Artifact Registry에 인증하도록 파이프라인을 구성할 수 있습니다. GitLab은 구성된 워크로드 아이덴티티 풀 IAM 정책을 사용하여 GOOGLE_APPLICATION_CREDENTIALSCLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE 환경 자격 증명을 채웁니다. 이러한 환경 자격 증명은 gcloud CLIcrane과 같은 클라이언트 도구에서 자동으로 감지됩니다.

Google Artifact Registry에 인증하려면 프로젝트의 .gitlab-ci.yml 파일에서 google_cloud로 설정된 identity 키워드를 사용합니다.

IAM 정책#

Google Cloud 프로젝트에는 Google Artifact Management 통합을 사용하기 위한 특정 IAM 정책이 있어야 합니다. 이 통합을 설정할 때 화면에 표시되는 지시에 따라 Google Cloud 프로젝트에 다음 IAM 정책을 만드는 단계가 안내됩니다:

이러한 IAM 정책을 수동으로 만들려면 다음 gcloud 명령을 사용합니다. 다음 값을 교체합니다:

  • <your_google_cloud_project_id>를 Artifact Registry 저장소가 위치한 Google Cloud 프로젝트의 ID로 교체합니다.
  • <your_workload_identity_pool_id>를 워크로드 아이덴티티 풀의 ID로 교체합니다. 이는 Google Cloud IAM 통합에 사용된 것과 동일한 값입니다.
  • <your_google_cloud_project_number>를 워크로드 아이덴티티 풀이 위치한 Google Cloud 프로젝트의 번호로 교체합니다. 이는 Google Cloud IAM 통합에 사용된 것과 동일한 값입니다.
gcloud projects add-iam-policy-binding '<your_google_cloud_project_id>' \
  --member='principalSet://iam.googleapis.com/projects/<your_google_cloud_project_number>/locations/global/workloadIdentityPools/<your_workload_identity_pool_id>/attribute.guest_access/true' \
  --role='roles/artifactregistry.reader'

gcloud projects add-iam-policy-binding '<your_google_cloud_project_id>' \
  --member='principalSet://iam.googleapis.com/projects/<your_google_cloud_project_number>/locations/global/workloadIdentityPools/<your_workload_identity_pool_id>/attribute.developer_access/true' \
  --role='roles/artifactregistry.writer'

사용 가능한 클레임 목록은 OIDC 사용자 정의 클레임을 참조하세요.

예시#

gcloud CLI를 사용하여 이미지 나열#

list-images:
  image: gcr.io/google.com/cloudsdktool/google-cloud-cli:466.0.0-alpine
  identity: google_cloud
  script:
    - gcloud artifacts docker images list $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app

crane을 사용하여 이미지 나열#

list-images:
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  identity: google_cloud
  before_script:
    # Temporary workaround for https://github.com/google/go-containerregistry/issues/1886
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - crane ls $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app

Docker로 이미지 가져오기#

다음 예시는 Google에서 제공하는 독립형 Docker 자격 증명 도우미로 Docker 인증을 설정하는 방법을 보여줍니다.

pull-image:
  image: docker:24.0.5-cli
  identity: google_cloud
  services:
    - docker:24.0.5-dind
  variables:
    # The following two variables ensure that the DinD service starts in TLS
    # mode and that the Docker CLI is properly configured to communicate with
    # the API. More details about the importance of this can be found at
    # https://docs.gitlab.com/ci/docker/using_docker_build/#use-the-docker-executor-with-docker-in-docker
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_CERTDIR: "/certs"
  before_script:
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - docker pull $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0

CI/CD 컴포넌트를 사용하여 이미지 복사#

Google은 GitLab 컨테이너 레지스트리에서 Artifact Registry로 이미지를 복사하는 데 사용할 수 있는 upload-artifact-registry CI/CD 컴포넌트를 제공합니다.

upload-artifact-registry 컴포넌트를 사용하려면 .gitlab-ci.yml에 다음을 추가합니다:

include:
  - component: gitlab.com/google-gitlab-components/artifact-registry/upload-artifact-registry@main
    inputs:
      stage: deploy
      source: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
      target: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA

자세한 내용은 컴포넌트 문서를 참조하세요.

upload-artifact-registry 컴포넌트를 사용하면 Artifact Registry로 이미지를 복사하는 것이 간소화되며 이 통합에 권장되는 방법입니다. Docker 또는 Crane을 사용하려면 다음 예시를 참조하세요.

Docker를 사용하여 이미지 복사#

다음 예시에서는 독립형 Docker 자격 증명 도우미 대신 gcloud CLI를 사용하여 Docker 인증을 설정합니다.

copy-image:
  image: gcr.io/google.com/cloudsdktool/google-cloud-cli:466.0.0-alpine
  identity: google_cloud
  services:
    - docker:24.0.5-dind
  variables:
    SOURCE_IMAGE: $CI_REGISTRY_IMAGE:v0.1.0
    TARGET_IMAGE: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0
    DOCKER_HOST: tcp://docker:2375
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - gcloud auth configure-docker $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - docker pull $SOURCE_IMAGE
    - docker tag $SOURCE_IMAGE $TARGET_IMAGE
    - docker push $TARGET_IMAGE

Crane을 사용하여 이미지 복사#

copy-image:
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  identity: google_cloud
  variables:
    SOURCE_IMAGE: $CI_REGISTRY_IMAGE:v0.1.0
    TARGET_IMAGE: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0
  before_script:
    # Temporary workaround for https://github.com/google/go-containerregistry/issues/1886
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - crane copy $SOURCE_IMAGE $TARGET_IMAGE

Google Artifact Management

Tier: Free, Premium, Ultimate
Offering: GitLab.com
원문 보기
요약

Google Artifact Management 통합을 사용하여 Google Artifact Registry 저장소를 GitLab 프로젝트에 구성하고 연결할 수 있습니다. Google Artifact Registry를 프로젝트에 연결한 후 Google Artifact Registry 저장소에서 Docker 및 OCI 이미지를 보고, 푸시하고, 가져올 수 있습니다.

히스토리

Google Artifact Management 통합을 사용하여 Google Artifact Registry 저장소를 GitLab 프로젝트에 구성하고 연결할 수 있습니다.

Google Artifact Registry를 프로젝트에 연결한 후 Google Artifact Registry 저장소에서 Docker 및 OCI 이미지를 보고, 푸시하고, 가져올 수 있습니다.

GitLab 프로젝트에서 Google Artifact Registry 설정#

사전 요구 사항:

  • GitLab 프로젝트에 대한 유지 관리자 또는 소유자 역할이 있어야 합니다.
  • Artifact Registry 저장소가 있는 Google Cloud 프로젝트에 대한 액세스를 관리하는 데 필요한 권한이 있어야 합니다.
  • Google Cloud에 인증하기 위해 워크로드 아이덴티티 페더레이션 (WLIF) 풀과 공급자가 구성되어 있어야 합니다.
  • 다음 구성의 Google Artifact Registry 저장소:
    • Docker 형식.
    • 표준 모드. 다른 저장소 형식과 모드는 지원되지 않습니다.

Google Artifact Registry 저장소를 GitLab 프로젝트에 연결하려면:

  1. 상단 바에서 검색 또는 이동을 선택하고 프로젝트를 찾습니다.
  2. 왼쪽 사이드바에서 설정 > 통합을 선택합니다.
  3. Google Artifact Management를 선택합니다.
  4. 통합 활성화에서 활성 체크박스를 선택합니다.
  5. 필드를 입력합니다:
  6. 화면의 지시에 따라 Google Cloud Identity and Access Management (IAM) 정책을 설정합니다. 정책 유형에 대한 자세한 내용은 IAM 정책을 참조하세요.
  7. 변경 사항 저장을 선택합니다.

이제 사이드바의 배포 아래에 Google Artifact Registry 항목이 표시됩니다.

Google Artifact Registry에 저장된 이미지 보기#

사전 요구 사항:

  • 프로젝트에 Google Artifact Registry가 구성되어 있어야 합니다.

GitLab UI에서 연결된 Artifact Registry 저장소의 이미지 목록을 보려면:

  1. 상단 바에서 검색 또는 이동을 선택하고 프로젝트를 찾습니다.
  2. 왼쪽 사이드바에서 배포 > Google Artifact Registry를 선택합니다.
  3. 이미지 세부 정보를 보려면 이미지를 선택합니다.
  4. Google Cloud 콘솔에서 이미지를 보려면 Google Cloud에서 열기를 선택합니다. 해당 Artifact Registry 저장소를 보려면 필요한 권한이 있어야 합니다.

CI/CD#

사전 정의 변수#

Artifact Registry 통합이 활성화되면 다음 사전 정의 환경 변수를 CI/CD에서 사용할 수 있습니다. 이러한 환경 변수를 사용하여 연결된 저장소에서 이미지를 가져오거나 푸시하는 등 Artifact Registry와 상호 작용할 수 있습니다.

Variable GitLab Runner Description
GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID 16.10 16.10 Artifact Registry 저장소가 위치한 Google Cloud 프로젝트 ID.
GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME 16.10 16.10 연결된 Artifact Registry 저장소의 이름.
GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION 16.10 16.10 연결된 Artifact Registry 저장소의 Google Cloud 위치.

Google Artifact Registry 인증#

파이프라인 실행 중 Google Artifact Registry에 인증하도록 파이프라인을 구성할 수 있습니다. GitLab은 구성된 워크로드 아이덴티티 풀 IAM 정책을 사용하여 GOOGLE_APPLICATION_CREDENTIALSCLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE 환경 자격 증명을 채웁니다. 이러한 환경 자격 증명은 gcloud CLIcrane과 같은 클라이언트 도구에서 자동으로 감지됩니다.

Google Artifact Registry에 인증하려면 프로젝트의 .gitlab-ci.yml 파일에서 google_cloud로 설정된 identity 키워드를 사용합니다.

IAM 정책#

Google Cloud 프로젝트에는 Google Artifact Management 통합을 사용하기 위한 특정 IAM 정책이 있어야 합니다. 이 통합을 설정할 때 화면에 표시되는 지시에 따라 Google Cloud 프로젝트에 다음 IAM 정책을 만드는 단계가 안내됩니다:

이러한 IAM 정책을 수동으로 만들려면 다음 gcloud 명령을 사용합니다. 다음 값을 교체합니다:

  • <your_google_cloud_project_id>를 Artifact Registry 저장소가 위치한 Google Cloud 프로젝트의 ID로 교체합니다.
  • <your_workload_identity_pool_id>를 워크로드 아이덴티티 풀의 ID로 교체합니다. 이는 Google Cloud IAM 통합에 사용된 것과 동일한 값입니다.
  • <your_google_cloud_project_number>를 워크로드 아이덴티티 풀이 위치한 Google Cloud 프로젝트의 번호로 교체합니다. 이는 Google Cloud IAM 통합에 사용된 것과 동일한 값입니다.
gcloud projects add-iam-policy-binding '<your_google_cloud_project_id>' \
  --member='principalSet://iam.googleapis.com/projects/<your_google_cloud_project_number>/locations/global/workloadIdentityPools/<your_workload_identity_pool_id>/attribute.guest_access/true' \
  --role='roles/artifactregistry.reader'

gcloud projects add-iam-policy-binding '<your_google_cloud_project_id>' \
  --member='principalSet://iam.googleapis.com/projects/<your_google_cloud_project_number>/locations/global/workloadIdentityPools/<your_workload_identity_pool_id>/attribute.developer_access/true' \
  --role='roles/artifactregistry.writer'

사용 가능한 클레임 목록은 OIDC 사용자 정의 클레임을 참조하세요.

예시#

gcloud CLI를 사용하여 이미지 나열#

list-images:
  image: gcr.io/google.com/cloudsdktool/google-cloud-cli:466.0.0-alpine
  identity: google_cloud
  script:
    - gcloud artifacts docker images list $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app

crane을 사용하여 이미지 나열#

list-images:
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  identity: google_cloud
  before_script:
    # Temporary workaround for https://github.com/google/go-containerregistry/issues/1886
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - crane ls $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app

Docker로 이미지 가져오기#

다음 예시는 Google에서 제공하는 독립형 Docker 자격 증명 도우미로 Docker 인증을 설정하는 방법을 보여줍니다.

pull-image:
  image: docker:24.0.5-cli
  identity: google_cloud
  services:
    - docker:24.0.5-dind
  variables:
    # The following two variables ensure that the DinD service starts in TLS
    # mode and that the Docker CLI is properly configured to communicate with
    # the API. More details about the importance of this can be found at
    # https://docs.gitlab.com/ci/docker/using_docker_build/#use-the-docker-executor-with-docker-in-docker
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_CERTDIR: "/certs"
  before_script:
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - docker pull $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0

CI/CD 컴포넌트를 사용하여 이미지 복사#

Google은 GitLab 컨테이너 레지스트리에서 Artifact Registry로 이미지를 복사하는 데 사용할 수 있는 upload-artifact-registry CI/CD 컴포넌트를 제공합니다.

upload-artifact-registry 컴포넌트를 사용하려면 .gitlab-ci.yml에 다음을 추가합니다:

include:
  - component: gitlab.com/google-gitlab-components/artifact-registry/upload-artifact-registry@main
    inputs:
      stage: deploy
      source: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
      target: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA

자세한 내용은 컴포넌트 문서를 참조하세요.

upload-artifact-registry 컴포넌트를 사용하면 Artifact Registry로 이미지를 복사하는 것이 간소화되며 이 통합에 권장되는 방법입니다. Docker 또는 Crane을 사용하려면 다음 예시를 참조하세요.

Docker를 사용하여 이미지 복사#

다음 예시에서는 독립형 Docker 자격 증명 도우미 대신 gcloud CLI를 사용하여 Docker 인증을 설정합니다.

copy-image:
  image: gcr.io/google.com/cloudsdktool/google-cloud-cli:466.0.0-alpine
  identity: google_cloud
  services:
    - docker:24.0.5-dind
  variables:
    SOURCE_IMAGE: $CI_REGISTRY_IMAGE:v0.1.0
    TARGET_IMAGE: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0
    DOCKER_HOST: tcp://docker:2375
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - gcloud auth configure-docker $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - docker pull $SOURCE_IMAGE
    - docker tag $SOURCE_IMAGE $TARGET_IMAGE
    - docker push $TARGET_IMAGE

Crane을 사용하여 이미지 복사#

copy-image:
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  identity: google_cloud
  variables:
    SOURCE_IMAGE: $CI_REGISTRY_IMAGE:v0.1.0
    TARGET_IMAGE: $GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev/$GOOGLE_ARTIFACT_REGISTRY_PROJECT_ID/$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_NAME/app:v0.1.0
  before_script:
    # Temporary workaround for https://github.com/google/go-containerregistry/issues/1886
    - wget -q "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.1.22/docker-credential-gcr_linux_amd64-2.1.22.tar.gz" -O - | tar xz -C /tmp && chmod +x /tmp/docker-credential-gcr && mv /tmp/docker-credential-gcr /usr/bin/
    - docker-credential-gcr configure-docker --registries=$GOOGLE_ARTIFACT_REGISTRY_REPOSITORY_LOCATION-docker.pkg.dev
  script:
    - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - crane copy $SOURCE_IMAGE $TARGET_IMAGE