-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
134 additions
and
660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,242 +1,7 @@ | ||
stages: | ||
- build-package | ||
- build-image | ||
- deploy | ||
include: | ||
- project: 'basicai/xtreme1/common' | ||
file: '/ci/template/xtreme1-app.yml' | ||
|
||
variables: | ||
APP_NAME: "xtreme1" | ||
APP_VERSION: "0.7.2" | ||
|
||
FRONTEND_PACKAGE_DIR: "dist" | ||
BACKEND_PACKAGE_NAME: "${APP_NAME}-backend-${APP_VERSION}-SNAPSHOT.jar" | ||
|
||
FRONTEND_IMAGE_NAME: "$CI_REGISTRY_IMAGE/frontend" | ||
BACKEND_IMAGE_NAME: "$CI_REGISTRY_IMAGE/backend" | ||
|
||
DOCKER_HUB_FRONTEND_IMAGE_NAME: "basicai/${APP_NAME}-frontend" | ||
DOCKER_HUB_BACKEND_IMAGE_NAME: "basicai/${APP_NAME}-backend" | ||
|
||
KUBERNETES_NAMESPACE: "x1-community" | ||
|
||
build-backend-package: | ||
stage: build-package | ||
tags: | ||
- openjdk-11 | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- backend/* | ||
- backend/**/* | ||
- if: $CI_COMMIT_TAG =~ /^v/ | ||
variables: | ||
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/backend/.m2/repository" | ||
MAVEN_ARGS: "--batch-mode" | ||
script: | ||
- cd backend | ||
- mvn $MAVEN_ARGS package | ||
artifacts: | ||
paths: | ||
- backend/target/$BACKEND_PACKAGE_NAME | ||
cache: | ||
paths: | ||
- backend/.m2/repository | ||
|
||
build-frontend-package: | ||
stage: build-package | ||
tags: | ||
- nodejs-16 | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- frontend/* | ||
- frontend/**/* | ||
- if: $CI_COMMIT_TAG =~ /^v/ | ||
script: | ||
- cd frontend/main | ||
- npm install | ||
- npm run build | ||
- cd ../image-tool | ||
- npm install | ||
- npm run build | ||
- cd ../pc-tool | ||
- npm install | ||
- npm run build | ||
- cd ../text-tool | ||
- npm install | ||
- npm run build | ||
artifacts: | ||
paths: | ||
- frontend/$FRONTEND_PACKAGE_DIR | ||
cache: | ||
paths: | ||
- frontend/main/node_modules | ||
- frontend/image-tool/node_modules | ||
- frontend/pc-tool/node_modules | ||
- frontend/text-tool/node_modules | ||
|
||
build-release-package: | ||
stage: build-package | ||
tags: | ||
- ubuntu | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- deploy/* | ||
- deploy/**/* | ||
- docker-compose.yml | ||
- if: $CI_COMMIT_TAG =~ /^v/ | ||
script: | ||
- ls | ||
artifacts: | ||
name: "${APP_NAME}-${CI_COMMIT_REF_NAME}" | ||
paths: | ||
- deploy/ | ||
- docker-compose.yml | ||
|
||
.build-image: | ||
stage: build-image | ||
tags: | ||
- docker | ||
variables: | ||
DOCKER_HOST: tcp://docker:2376 | ||
DOCKER_TLS_CERTDIR: "/certs" | ||
DOCKER_TLS_VERIFY: 1 | ||
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" | ||
services: | ||
- docker:20-dind | ||
before_script: | ||
- until docker info; do sleep 1; done | ||
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY | ||
- docker login -u $DOCKER_HUB_REGISTRY_USER -p $DOCKER_HUB_REGISTRY_PASS | ||
after_script: | ||
- cd $WORKING_DIR | ||
- docker pull $IMAGE_NAME:latest || true | ||
- docker build --cache-from $IMAGE_NAME:latest -t $IMAGE_NAME:$CI_COMMIT_REF_NAME -t $IMAGE_NAME:$CI_COMMIT_SHORT_SHA -t $IMAGE_NAME:latest . | ||
- docker push $IMAGE_NAME:$CI_COMMIT_REF_NAME | ||
- docker push $IMAGE_NAME:$CI_COMMIT_SHORT_SHA | ||
- docker push $IMAGE_NAME:latest | ||
# Push main and tag image to Docker Hub. | ||
# - if [[ $CI_COMMIT_REF_NAME == main ]]; then docker tag $IMAGE_NAME:$CI_COMMIT_REF_NAME $DOCKER_HUB_IMAGE_NAME:latest; docker push $DOCKER_HUB_IMAGE_NAME:latest; fi | ||
# - if [[ $CI_COMMIT_REF_NAME == v* ]]; then docker tag $IMAGE_NAME:$CI_COMMIT_REF_NAME $DOCKER_HUB_IMAGE_NAME:$CI_COMMIT_REF_NAME; docker push $DOCKER_HUB_IMAGE_NAME:$CI_COMMIT_REF_NAME; fi | ||
|
||
build-backend-image: | ||
extends: .build-image | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- backend/* | ||
- backend/**/* | ||
- if: $CI_COMMIT_TAG =~ /^v/ | ||
variables: | ||
WORKING_DIR: backend | ||
IMAGE_NAME: $BACKEND_IMAGE_NAME | ||
DOCKER_HUB_IMAGE_NAME: $DOCKER_HUB_BACKEND_IMAGE_NAME | ||
script: | ||
- cd $WORKING_DIR | ||
- cp ../.ops/backend.dockerfile ./Dockerfile | ||
- cp ../.ops/backend.dockerignore ./.dockerignore | ||
- sed -i 's/$BACKEND_PACKAGE_NAME/'"$BACKEND_PACKAGE_NAME"'/g' Dockerfile | ||
|
||
build-frontend-image: | ||
extends: .build-image | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- frontend/* | ||
- frontend/**/* | ||
- if: $CI_COMMIT_TAG =~ /^v/ | ||
variables: | ||
WORKING_DIR: frontend | ||
IMAGE_NAME: $FRONTEND_IMAGE_NAME | ||
DOCKER_HUB_IMAGE_NAME: $DOCKER_HUB_FRONTEND_IMAGE_NAME | ||
script: | ||
- cd $WORKING_DIR | ||
- cp ../.ops/frontend.dockerfile ./Dockerfile | ||
- cp ../.ops/frontend.dockerignore ./.dockerignore | ||
- sed -i 's/$FRONTEND_PACKAGE_DIR/'"$FRONTEND_PACKAGE_DIR"'/g' Dockerfile | ||
|
||
.deploy: | ||
stage: deploy | ||
tags: | ||
- kubectl | ||
before_script: | ||
- cd .ops/$ENV | ||
- sed -i 's/$APP_NAME/'"$APP_NAME"'/g' $DEPLOYMENT | ||
- sed -i 's/$APP_VERSION/'"$APP_VERSION"'/g' $DEPLOYMENT | ||
- sed -i 's/$CI_COMMIT_SHORT_SHA/'"$CI_COMMIT_SHORT_SHA"'/g' $DEPLOYMENT | ||
|
||
deploy-backend-to-alidev: | ||
extends: .deploy | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- backend/* | ||
- backend/**/* | ||
variables: | ||
ENV: alidev | ||
DEPLOYMENT: backend-deployment.yml | ||
script: | ||
- sed -i 's|$BACKEND_IMAGE_NAME|'"$BACKEND_IMAGE_NAME"'|g' $DEPLOYMENT | ||
- kubectl apply -f $DEPLOYMENT -n $KUBERNETES_NAMESPACE --kubeconfig=$KUBECONFIG_ALIYUN_DEVELOPMENT | ||
|
||
deploy-frontend-to-alidev: | ||
extends: .deploy | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- frontend/* | ||
- frontend/**/* | ||
variables: | ||
ENV: alidev | ||
DEPLOYMENT: frontend-deployment.yml | ||
script: | ||
- sed -i 's|$FRONTEND_IMAGE_NAME|'"$FRONTEND_IMAGE_NAME"'|g' $DEPLOYMENT | ||
- kubectl apply -f $DEPLOYMENT -n $KUBERNETES_NAMESPACE --kubeconfig=$KUBECONFIG_ALIYUN_DEVELOPMENT | ||
|
||
deploy-backend-to-alitest: | ||
extends: .deploy | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- backend/* | ||
- backend/**/* | ||
when: manual | ||
variables: | ||
ENV: alitest | ||
DEPLOYMENT: backend-deployment.yml | ||
script: | ||
- sed -i 's|$BACKEND_IMAGE_NAME|'"$BACKEND_IMAGE_NAME"'|g' $DEPLOYMENT | ||
- kubectl apply -f $DEPLOYMENT -n $KUBERNETES_NAMESPACE --kubeconfig=$KUBECONFIG_ALIYUN_TESTING | ||
|
||
deploy-frontend-to-alitest: | ||
extends: .deploy | ||
rules: | ||
- if: $CI_COMMIT_BRANCH == "dev" | ||
changes: | ||
- .ops/* | ||
- .ops/**/* | ||
- frontend/* | ||
- frontend/**/* | ||
when: manual | ||
variables: | ||
ENV: alitest | ||
DEPLOYMENT: frontend-deployment.yml | ||
script: | ||
- sed -i 's|$FRONTEND_IMAGE_NAME|'"$FRONTEND_IMAGE_NAME"'|g' $DEPLOYMENT | ||
- kubectl apply -f $DEPLOYMENT -n $KUBERNETES_NAMESPACE --kubeconfig=$KUBECONFIG_ALIYUN_TESTING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.