feat: 创建 Spring Boot 4 项目及 Gitea/GitLab CI/CD 流水线
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
25
.gitlab-ci.yml
Normal file
25
.gitlab-ci.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
image: docker:27.3.1-cli
|
||||
|
||||
services:
|
||||
- name: docker:27.3.1-dind
|
||||
alias: docker
|
||||
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2376
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
||||
IMAGE: registry.cn-hangzhou.aliyuncs.com/lightjob/springboot-cici-demo
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
build-and-push:
|
||||
stage: build
|
||||
script:
|
||||
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USERNAME" --password-stdin
|
||||
- SHORT_SHA=$(echo "$CI_COMMIT_SHA" | cut -c1-7)
|
||||
- docker build -t "$IMAGE:$SHORT_SHA" -t "$IMAGE:latest" .
|
||||
- docker push "$IMAGE:$SHORT_SHA"
|
||||
- docker push "$IMAGE:latest"
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
Reference in New Issue
Block a user