Skip to content

Commit

Permalink
Removed length limit for registry_project_path, add gcp method for gi…
Browse files Browse the repository at this point in the history
…tlab-ci
  • Loading branch information
Syakyr committed Mar 14, 2024
1 parent 687c57c commit 6adc5af
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def check_cookiecutter_inputs():
global ERROR_MSG_LIST

for cookie_input_key, cookie_input_val in COOKIE_INPUTS.items():
check_input_length(cookie_input_key, cookie_input_val)
if cookie_input_key != 'registry_project_path':
check_input_length(cookie_input_key, cookie_input_val)
if "regex" in cookie_input_val:
check_input_regex(cookie_input_key, cookie_input_val)
if "avail" in cookie_input_val:
Expand Down
46 changes: 46 additions & 0 deletions {{cookiecutter.repo_name}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
default:
tags:
{%- if cookiecutter.platform == 'onprem' %}
- on-prem
{%- elif cookiecutter.platform == 'gcp' %}
- gcp
{%- endif %}

stages:
- test
Expand Down Expand Up @@ -71,11 +75,23 @@ build:data-prep-image:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
{%- if cookiecutter.platform == 'gcp' %}
variables:
GOOGLE_APPLICATION_CREDENTIALS: /kaniko/.docker/config.json
{%- endif %}
before_script:
{%- if cookiecutter.platform == 'onprem' %}
- "[[ -z ${HARBOR_ROBOT_CREDS_JSON} ]] && echo 'HARBOR_ROBOT_CREDS_JSON variable is not set.' && exit 1"
{%- elif cookiecutter.platform == 'gcp' %}
- "[[ -z ${GCP_SERVICE_ACCOUNT_KEY} ]] && echo 'GCP_SERVICE_ACCOUNT_KEY variable is not set.' && exit 1"
{%- endif %}
script:
- mkdir -p /kaniko/.docker
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
{%- endif %}
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
Expand All @@ -98,11 +114,23 @@ build:model-training-image:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
{%- if cookiecutter.platform == 'gcp' %}
variables:
GOOGLE_APPLICATION_CREDENTIALS: /kaniko/.docker/config.json
{%- endif %}
before_script:
{%- if cookiecutter.platform == 'onprem' %}
- "[[ -z ${HARBOR_ROBOT_CREDS_JSON} ]] && echo 'HARBOR_ROBOT_CREDS_JSON variable is not set.' && exit 1"
{%- elif cookiecutter.platform == 'gcp' %}
- "[[ -z ${GCP_SERVICE_ACCOUNT_KEY} ]] && echo 'GCP_SERVICE_ACCOUNT_KEY variable is not set.' && exit 1"
{%- endif %}
script:
- mkdir -p /kaniko/.docker
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /kaniko/.docker/config.json
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /kaniko/.docker/config.json
{%- endif %}
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
Expand All @@ -123,13 +151,31 @@ build:model-training-image:
build:retag-images:
stage: build
image:
{%- if cookiecutter.platform == 'onprem' %}
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
{%- elif cookiecutter.platform == 'gcp' %}
name: google/cloud-sdk:debian_component_based
{%- endif %}
{%- if cookiecutter.platform == 'gcp' %}
variables:
GOOGLE_APPLICATION_CREDENTIALS: /gcp-sa.json
{%- endif %}
before_script:
{%- if cookiecutter.platform == 'onprem' %}
- "[[ -z ${HARBOR_ROBOT_CREDS_JSON} ]] && echo 'HARBOR_ROBOT_CREDS_JSON variable is not set.' && exit 1"
{%- elif cookiecutter.platform == 'gcp' %}
- "[[ -z ${GCP_SERVICE_ACCOUNT_KEY} ]] && echo 'GCP_SERVICE_ACCOUNT_KEY variable is not set.' && exit 1"
{%- endif %}
script:
{%- if cookiecutter.platform == 'onprem' %}
- cat $HARBOR_ROBOT_CREDS_JSON > /root/.docker/config.json
- crane tag {{cookiecutter.registry_project_path}}/data-prep:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
- crane tag {{cookiecutter.registry_project_path}}/model-training:${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TAG}
{%- elif cookiecutter.platform == 'gcp' %}
- cat $GCP_SERVICE_ACCOUNT_KEY > /gcp-sa.json
- gcloud container images add-tag --quiet "{{cookiecutter.registry_project_path}}/data-prep:${CI_COMMIT_TAG}"
- gcloud container images add-tag --quiet "{{cookiecutter.registry_project_path}}/model-training:${CI_COMMIT_TAG}"
{%- endif %}
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

0 comments on commit 6adc5af

Please sign in to comment.