From e6ff1f5ca4eab330d70d2a00cbe0bfebe93478dd Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 03:10:24 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9ad5cc7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +# You can copy and paste this template into a new `.gitlab-ci.yml` file. +# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. +# +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml + +image: golang:latest + +stages: + - test + - build + - deploy + +format: + stage: test + script: + - go fmt $(go list ./... | grep -v /vendor/) + - go vet $(go list ./... | grep -v /vendor/) + - go test -race $(go list ./... | grep -v /vendor/) + +compile: + stage: build + script: + - make + artifacts: + paths: + - openai-api-route + +deploy: + stage: deploy + script: echo "Define your deployment script!" + environment: production From 34aa4babc4a5f56bdb1556de0eb38885c1c010c0 Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 03:21:24 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9ad5cc7..170fa57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,26 +9,38 @@ image: golang:latest stages: - - test - build - deploy -format: - stage: test - script: - - go fmt $(go list ./... | grep -v /vendor/) - - go vet $(go list ./... | grep -v /vendor/) - - go test -race $(go list ./... | grep -v /vendor/) - -compile: +build: + # Use the official docker image. + image: docker:cli stage: build + services: + - docker:dind + variables: + DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug) + # Default branch is also tagged with `latest` script: - - make - artifacts: - paths: - - openai-api-route + - docker build --pull -t "$DOCKER_IMAGE_NAME" . + - docker push "$DOCKER_IMAGE_NAME" + - | + if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then + docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest" + docker push "$CI_REGISTRY_IMAGE:latest" + fi + # Run this job in a branch where a Dockerfile exists + rules: + - if: $CI_COMMIT_BRANCH + exists: + - Dockerfile deploy: stage: deploy script: echo "Define your deployment script!" environment: production + + From 8b95fbb5da75a06cb565b7888b46f9284a9e213a Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 03:40:32 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 170fa57..7d0bd70 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ build: variables: DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" https://gitlab.waykey.net:7999 # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug) # Default branch is also tagged with `latest` script: From e442303847868ad3771f2a21aae426570a49e716 Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 03:52:19 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7d0bd70..bb5d5f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,27 +1,26 @@ -# You can copy and paste this template into a new `.gitlab-ci.yml` file. -# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. -# # To contribute improvements to CI/CD templates, please follow the Development guide at: # https://docs.gitlab.com/ee/development/cicd/templates.html # This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml -image: golang:latest +# Build a Docker image with CI/CD and push to the GitLab registry. +# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html +# +# This template uses one generic job with conditional builds +# for the default branch and all other (MR) branches. -stages: - - build - - deploy - -build: +docker-build: # Use the official docker image. image: docker:cli stage: build services: - docker:dind variables: + CI_REGISTRY: www.waykey.net:7999 + CI_REGISTRY_IMAGE: $CI_REGISTRY/spiderman/datamining/openai-api-route DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" https://gitlab.waykey.net:7999 + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug) # Default branch is also tagged with `latest` script: @@ -38,9 +37,3 @@ build: exists: - Dockerfile -deploy: - stage: deploy - script: echo "Define your deployment script!" - environment: production - - From 24a2e609f82c788c224697eb94fe46f5557d9eae Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 05:11:47 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb5d5f3..c753bac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ docker-build: services: - docker:dind variables: - CI_REGISTRY: www.waykey.net:7999 + CI_REGISTRY: gitlab.waykey.net:7999 CI_REGISTRY_IMAGE: $CI_REGISTRY/spiderman/datamining/openai-api-route DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG before_script: From e373e3ac63cc0381729d41993cf501f5b4934d86 Mon Sep 17 00:00:00 2001 From: CHEN Yongyuan Date: Mon, 8 Apr 2024 07:48:05 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0.gitlab-ci.yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c753bac..8d8e5b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ docker-build: services: - docker:dind variables: - CI_REGISTRY: gitlab.waykey.net:7999 + CI_REGISTRY: registry.waykey.net:7999 CI_REGISTRY_IMAGE: $CI_REGISTRY/spiderman/datamining/openai-api-route DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG before_script: