diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8504a47adab1707fc74148b308c0dae6c766c600..5a86ff38feced5e7cff70fa9a2cecf16f443068c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,6 +89,20 @@ gitlab-opentofu-image:build: stage: build image: quay.io/containers/buildah:v1.37.3 before_script: + # Supporting GitLab dependency proxies: + # see https://docs.gitlab.com/ee/user/packages/dependency_proxy/ + - | + if [ -n "$CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX" ]; then + echo "Detected GitLab Dependency Proxy at '$CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX', configuring it for buildah ..." + cat > /etc/containers/registries.conf.d/dependency-proxy.conf <<EOF + [[registry]] + location = "docker.io" + [[registry.mirror]] + location = "${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}" + EOF + + buildah login -u "$CI_DEPENDENCY_PROXY_USER" -p "$CI_DEPENDENCY_PROXY_PASSWORD" "$CI_DEPENDENCY_PROXY_SERVER" + fi - buildah login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" script: - echo "Building $GITLAB_OPENTOFU_IMAGE_NAME" diff --git a/.gitlab/README.md.template b/.gitlab/README.md.template index e7008ecb05bef48fc8982eefe0945a5c9c068c47..a1ad5a75a5d3fdfa0896ae43b314f6e7092277cf 100644 --- a/.gitlab/README.md.template +++ b/.gitlab/README.md.template @@ -396,6 +396,11 @@ See also the official GitLab documentation for it If you want to save runner resources you may disable the unit and integration tests by setting the `SKIP_TESTS` CI/CD variable to `true`. +The pipeline of this component respects the +[GitLab Dependency Proxy](https://docs.gitlab.com/ee/user/packages/dependency_proxy/) configuration +by detecting the `CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX` environment variable +and configuring `buildah` to use it when building the container images. + ## Migrating from the Terraform CI/CD templates When migrating from the GitLab Terraform CI/CD templates you can use the following migration rules: diff --git a/README.md b/README.md index a3b0c2ab6e2fb0f3a44df72d4a28ea1b1f874374..1a1eefe8be46748aefe50ca78e95d97579eba5b4 100644 --- a/README.md +++ b/README.md @@ -415,6 +415,11 @@ See also the official GitLab documentation for it If you want to save runner resources you may disable the unit and integration tests by setting the `SKIP_TESTS` CI/CD variable to `true`. +The pipeline of this component respects the +[GitLab Dependency Proxy](https://docs.gitlab.com/ee/user/packages/dependency_proxy/) configuration +by detecting the `CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX` environment variable +and configuring `buildah` to use it when building the container images. + ## Migrating from the Terraform CI/CD templates When migrating from the GitLab Terraform CI/CD templates you can use the following migration rules: