Loading .gitlab-ci.d/registry.yml 0 → 100644 +139 Changes for .gitlab-ci.d/registry.yml: 139 added lines, 0 removed lines. Original line number Diff line number Diff line spec: inputs: stage: default: test description: 'Defines the registry stage (Default: test)' image: default: docker:27-cli description: 'Specify the registry image (Default: docker:27-cli)' --- .registry: stage: $[[ inputs.stage ]] image: $[[ inputs.image ]] services: - docker:dind before_script: # Configure registry - | if [ ! -z "${CI_REGISTRY}" ]; then docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}" fi after_script: # Cleanup intermediates - docker system prune --force variables: DOCKER_DRIVER: overlay2 registry:rehost: extends: - .registry stage: $[[ inputs.stage ]] needs: [] script: # Rehost standard images - | set +x for base_rename in $(cat ./containers/rehost/images.txt); do base=$(echo "${base_rename}" | cut -d'|' -f1) rename=$(echo "${base_rename}" | cut -d'|' -f2) image="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/${REGISTRY_PROJECT}/${rename:-${base}}" if [ -z "${IMAGE}" ] || echo "${image}" | grep -q "${IMAGE}"; then base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi echo ' ' echo " [INFO] Pull: ${base}" echo ' ' docker pull "${base}" || true docker tag "${base}" "${image}" echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" || true if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi fi done rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: - containers/rehost/images.txt .registry:container: extends: - .registry stage: $[[ inputs.stage ]] needs: - job: registry:rehost artifacts: false optional: true variables: BASEIMAGE_NAME: undefined:latest CONTAINER_FOLDER: undefined CONTAINER_IMAGE_TAG: undefined script: # Prepare container image - export base="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${BASEIMAGE_NAME}" - export image="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${REGISTRY_PROJECT:?}:${CONTAINER_IMAGE_TAG:?}" # Detect local image - | base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi # Pull images - | echo ' ' echo " [INFO] Pull: ${image}" echo ' ' docker pull "${base}" || true docker pull "${image}" || true # Build image - | docker buildx build \ --build-arg "IMAGE_BASE=${base}" \ --build-context 'requirements=./requirements' \ --cache-from "${image}" \ --pull \ --tag "${image}" \ "./containers/${CONTAINER_FOLDER}/" # Cleanup intermediates - docker system prune --force # Show images - docker images # Push image - | if [ ! -z "${CI_COMMIT_TAG}" ] || [ "${CI_COMMIT_REF_NAME}" = "${CI_DEFAULT_BRANCH:-undefined}" ] || [ "${PUSH_IMAGES:-false}" = 'true' ]; then echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" fi # Cleanup images - | if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # changes: # - containers/undefined/Dockerfile # - containers/rehost/images.txt # - requirements/undefined.txt .gitlab-ci.yml +19 −172 Changes for .gitlab-ci.yml: 19 added lines, 172 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ include: - component: gitlab.com/RadianDevCore/tools/pre-commit-crocodile/commits@5.0.0 inputs: stage: prepare - local: .gitlab-ci.d/registry.yml inputs: stage: registry - local: .gitlab-ci.d/install.yml inputs: stage: build Loading Loading @@ -44,9 +47,6 @@ variables: volumes: - ${HOME}/.docker/config.json:/root/.docker/config.json:ro # ============================================================================= # Stage: development clean: stage: development image: local Loading Loading @@ -115,129 +115,11 @@ hooks: rules: - if: $CI_LOCAL # ============================================================================= # Stage: registry .registry: image: docker:27-cli services: - docker:dind before_script: # Configure registry - | if [ ! -z "${CI_REGISTRY}" ]; then docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}" fi script: # Prepare container image - export base="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${BASEIMAGE_NAME}" - export image="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${REGISTRY_PROJECT:?}:${CONTAINER_IMAGE_TAG:?}" # Detect local image - | base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi # Pull images - | echo ' ' echo " [INFO] Pull: ${image}" echo ' ' docker pull "${base}" || true docker pull "${image}" || true # Build image - | docker buildx build \ --build-arg "IMAGE_BASE=${base}" \ --build-context 'requirements=./requirements' \ --cache-from "${image}" \ --pull \ --tag "${image}" \ "./containers/${CONTAINER_FOLDER}/" # Cleanup intermediates - docker system prune --force # Show images - docker images # Push image - | if [ ! -z "${CI_COMMIT_TAG}" ] || [ "${CI_COMMIT_REF_NAME}" = "${CI_DEFAULT_BRANCH:-undefined}" ] || [ "${PUSH_IMAGES:-false}" = 'true' ]; then echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" fi # Cleanup images - | if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi after_script: # Cleanup intermediates - docker system prune --force variables: DOCKER_DRIVER: overlay2 registry:rehost: stage: registry extends: - .registry needs: [] script: # Rehost standard images - | set +x for base_rename in $(cat ./containers/rehost/images.txt); do base=$(echo "${base_rename}" | cut -d'|' -f1) rename=$(echo "${base_rename}" | cut -d'|' -f2) image="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/${REGISTRY_PROJECT}/${rename:-${base}}" if [ -z "${IMAGE}" ] || echo "${image}" | grep -q "${IMAGE}"; then base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi echo ' ' echo " [INFO] Pull: ${base}" echo ' ' docker pull "${base}" || true docker tag "${base}" "${image}" echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" || true if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi fi done rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: - containers/rehost/images.txt registry:build: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: build CONTAINER_IMAGE_TAG: build rules: Loading @@ -249,15 +131,10 @@ registry:build: - requirements/runtime.txt registry:codestyle: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: codestyle CONTAINER_IMAGE_TAG: codestyle rules: Loading @@ -270,15 +147,10 @@ registry:codestyle: - requirements/tests.txt registry:deploy: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: deploy CONTAINER_IMAGE_TAG: deploy rules: Loading @@ -289,15 +161,10 @@ registry:deploy: - requirements/deploy.txt registry:pages: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-slim' BASEIMAGE_NAME: python:3.12-slim CONTAINER_FOLDER: pages CONTAINER_IMAGE_TAG: pages rules: Loading @@ -309,15 +176,10 @@ registry:pages: - requirements/pages.txt registry:test-coverage-linux: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12' BASEIMAGE_NAME: python:3.12 CONTAINER_FOLDER: test-coverage-linux CONTAINER_IMAGE_TAG: test-coverage-linux rules: Loading @@ -330,15 +192,10 @@ registry:test-coverage-linux: - requirements/tests.txt registry:test-coverage-windows: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'tobix/pywine:3.10' BASEIMAGE_NAME: tobix/pywine:3.10 CONTAINER_FOLDER: test-coverage-windows CONTAINER_IMAGE_TAG: test-coverage-windows rules: Loading @@ -351,15 +208,10 @@ registry:test-coverage-windows: - requirements/tests.txt registry:test-oldest: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.8' BASEIMAGE_NAME: python:3.8 CONTAINER_FOLDER: test-linux CONTAINER_IMAGE_TAG: test-oldest rules: Loading @@ -370,15 +222,10 @@ registry:test-oldest: - requirements/tests.txt registry:test-latest: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12' BASEIMAGE_NAME: python:3.12 CONTAINER_FOLDER: test-linux CONTAINER_IMAGE_TAG: test-latest rules: Loading Loading
.gitlab-ci.d/registry.yml 0 → 100644 +139 Changes for .gitlab-ci.d/registry.yml: 139 added lines, 0 removed lines. Original line number Diff line number Diff line spec: inputs: stage: default: test description: 'Defines the registry stage (Default: test)' image: default: docker:27-cli description: 'Specify the registry image (Default: docker:27-cli)' --- .registry: stage: $[[ inputs.stage ]] image: $[[ inputs.image ]] services: - docker:dind before_script: # Configure registry - | if [ ! -z "${CI_REGISTRY}" ]; then docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}" fi after_script: # Cleanup intermediates - docker system prune --force variables: DOCKER_DRIVER: overlay2 registry:rehost: extends: - .registry stage: $[[ inputs.stage ]] needs: [] script: # Rehost standard images - | set +x for base_rename in $(cat ./containers/rehost/images.txt); do base=$(echo "${base_rename}" | cut -d'|' -f1) rename=$(echo "${base_rename}" | cut -d'|' -f2) image="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/${REGISTRY_PROJECT}/${rename:-${base}}" if [ -z "${IMAGE}" ] || echo "${image}" | grep -q "${IMAGE}"; then base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi echo ' ' echo " [INFO] Pull: ${base}" echo ' ' docker pull "${base}" || true docker tag "${base}" "${image}" echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" || true if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi fi done rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: - containers/rehost/images.txt .registry:container: extends: - .registry stage: $[[ inputs.stage ]] needs: - job: registry:rehost artifacts: false optional: true variables: BASEIMAGE_NAME: undefined:latest CONTAINER_FOLDER: undefined CONTAINER_IMAGE_TAG: undefined script: # Prepare container image - export base="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${BASEIMAGE_NAME}" - export image="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${REGISTRY_PROJECT:?}:${CONTAINER_IMAGE_TAG:?}" # Detect local image - | base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi # Pull images - | echo ' ' echo " [INFO] Pull: ${image}" echo ' ' docker pull "${base}" || true docker pull "${image}" || true # Build image - | docker buildx build \ --build-arg "IMAGE_BASE=${base}" \ --build-context 'requirements=./requirements' \ --cache-from "${image}" \ --pull \ --tag "${image}" \ "./containers/${CONTAINER_FOLDER}/" # Cleanup intermediates - docker system prune --force # Show images - docker images # Push image - | if [ ! -z "${CI_COMMIT_TAG}" ] || [ "${CI_COMMIT_REF_NAME}" = "${CI_DEFAULT_BRANCH:-undefined}" ] || [ "${PUSH_IMAGES:-false}" = 'true' ]; then echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" fi # Cleanup images - | if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # changes: # - containers/undefined/Dockerfile # - containers/rehost/images.txt # - requirements/undefined.txt
.gitlab-ci.yml +19 −172 Changes for .gitlab-ci.yml: 19 added lines, 172 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ include: - component: gitlab.com/RadianDevCore/tools/pre-commit-crocodile/commits@5.0.0 inputs: stage: prepare - local: .gitlab-ci.d/registry.yml inputs: stage: registry - local: .gitlab-ci.d/install.yml inputs: stage: build Loading Loading @@ -44,9 +47,6 @@ variables: volumes: - ${HOME}/.docker/config.json:/root/.docker/config.json:ro # ============================================================================= # Stage: development clean: stage: development image: local Loading Loading @@ -115,129 +115,11 @@ hooks: rules: - if: $CI_LOCAL # ============================================================================= # Stage: registry .registry: image: docker:27-cli services: - docker:dind before_script: # Configure registry - | if [ ! -z "${CI_REGISTRY}" ]; then docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}" fi script: # Prepare container image - export base="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${BASEIMAGE_NAME}" - export image="${REGISTRY_HOST:?}/${REGISTRY_NAMESPACE:?}/${REGISTRY_PROJECT:?}/${REGISTRY_PROJECT:?}:${CONTAINER_IMAGE_TAG:?}" # Detect local image - | base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi # Pull images - | echo ' ' echo " [INFO] Pull: ${image}" echo ' ' docker pull "${base}" || true docker pull "${image}" || true # Build image - | docker buildx build \ --build-arg "IMAGE_BASE=${base}" \ --build-context 'requirements=./requirements' \ --cache-from "${image}" \ --pull \ --tag "${image}" \ "./containers/${CONTAINER_FOLDER}/" # Cleanup intermediates - docker system prune --force # Show images - docker images # Push image - | if [ ! -z "${CI_COMMIT_TAG}" ] || [ "${CI_COMMIT_REF_NAME}" = "${CI_DEFAULT_BRANCH:-undefined}" ] || [ "${PUSH_IMAGES:-false}" = 'true' ]; then echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" fi # Cleanup images - | if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi after_script: # Cleanup intermediates - docker system prune --force variables: DOCKER_DRIVER: overlay2 registry:rehost: stage: registry extends: - .registry needs: [] script: # Rehost standard images - | set +x for base_rename in $(cat ./containers/rehost/images.txt); do base=$(echo "${base_rename}" | cut -d'|' -f1) rename=$(echo "${base_rename}" | cut -d'|' -f2) image="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/${REGISTRY_PROJECT}/${rename:-${base}}" if [ -z "${IMAGE}" ] || echo "${image}" | grep -q "${IMAGE}"; then base_local='false' image_local='false' if docker images -q "${base}" 2>/dev/null | grep -q '.'; then base_local='true' fi if docker images -q "${image}" 2>/dev/null | grep -q '.'; then image_local='true' fi echo ' ' echo " [INFO] Pull: ${base}" echo ' ' docker pull "${base}" || true docker tag "${base}" "${image}" echo ' ' echo " [INFO] Push: ${image}" echo ' ' docker push "${image}" || true if [ ! -z "${CI_LOCAL:-}" ] && [ "${base_local}" = 'false' ]; then docker rmi "${base}" >/dev/null || true fi if [ ! -z "${CI_LOCAL:-}" ] && [ "${image_local}" = 'false' ]; then docker rmi "${image}" >/dev/null || true fi fi done rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: - containers/rehost/images.txt registry:build: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: build CONTAINER_IMAGE_TAG: build rules: Loading @@ -249,15 +131,10 @@ registry:build: - requirements/runtime.txt registry:codestyle: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: codestyle CONTAINER_IMAGE_TAG: codestyle rules: Loading @@ -270,15 +147,10 @@ registry:codestyle: - requirements/tests.txt registry:deploy: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-alpine' BASEIMAGE_NAME: python:3.12-alpine CONTAINER_FOLDER: deploy CONTAINER_IMAGE_TAG: deploy rules: Loading @@ -289,15 +161,10 @@ registry:deploy: - requirements/deploy.txt registry:pages: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12-slim' BASEIMAGE_NAME: python:3.12-slim CONTAINER_FOLDER: pages CONTAINER_IMAGE_TAG: pages rules: Loading @@ -309,15 +176,10 @@ registry:pages: - requirements/pages.txt registry:test-coverage-linux: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12' BASEIMAGE_NAME: python:3.12 CONTAINER_FOLDER: test-coverage-linux CONTAINER_IMAGE_TAG: test-coverage-linux rules: Loading @@ -330,15 +192,10 @@ registry:test-coverage-linux: - requirements/tests.txt registry:test-coverage-windows: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'tobix/pywine:3.10' BASEIMAGE_NAME: tobix/pywine:3.10 CONTAINER_FOLDER: test-coverage-windows CONTAINER_IMAGE_TAG: test-coverage-windows rules: Loading @@ -351,15 +208,10 @@ registry:test-coverage-windows: - requirements/tests.txt registry:test-oldest: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.8' BASEIMAGE_NAME: python:3.8 CONTAINER_FOLDER: test-linux CONTAINER_IMAGE_TAG: test-oldest rules: Loading @@ -370,15 +222,10 @@ registry:test-oldest: - requirements/tests.txt registry:test-latest: stage: registry extends: - .registry needs: - job: registry:rehost artifacts: false optional: true - .registry:container variables: BASEIMAGE_NAME: 'python:3.12' BASEIMAGE_NAME: python:3.12 CONTAINER_FOLDER: test-linux CONTAINER_IMAGE_TAG: test-latest rules: Loading