LLMX/.gitlab/workflows/.gitlab-ci.test.yml
gewuyou 57d8f904e3 refactor(docker): 更新 Docker Compose 配置
- 修改 llmx-core-database 服务名称为 llmx-database
- 更新数据库容器的 volume 名称
-统一网络和 volume 的命名格式
2025-05-13 13:32:44 +08:00

98 lines
2.5 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

stages:
- build
- deploy
variables:
PROJECT_NAME: llmx
COMPOSE_FILE: docker/docker-compose.test.yml
SERVER_PASSWORD: $SERVER_PASSWORD
DOCKER_REGISTRY_URL: $DOCKER_REGISTRY_URL
SPRING_PROFILES_ACTIVE: test
before_script:
- export GRADLE_USER_HOME=$CI_PROJECT_DIR/.gradle
build:
stage: build
environment:
name: test
rules:
- if: '$CI_COMMIT_BRANCH == "test"'
cache:
key:
files:
- gradle/libs.versions.toml
- "**/build.gradle.kts"
prefix: $CI_JOB_NAME
paths:
- .gradle/caches/
- .gradle/wrapper/
- .gradle/kotlin-profile/
- .kotlin/
policy: pull-push
script:
- |
echo "=== 🐳 检查 Docker 安装状态 ==="
if ! command -v docker >/dev/null; then
echo "❌ Docker 未安装,开始安装..."
curl -fsSL https://get.docker.com | sh | tee docker-install.log
echo "✅ Docker 安装完成"
else
echo " Docker 已安装: $(docker -v)"
echo " Docker Compose 已安装: $(docker compose version)"
fi
- echo "🔧 授予 gradlew 执行权限..."
- chmod +x gradlew
- echo "🚀 开始构建 Docker 镜像..."
- ./gradlew jib --stacktrace --build-cache --info -Dorg.gradle.caching=true -Dorg.gradle.jvmargs="-Xmx2g -Xms2g -XX:MaxMetaspaceSize=1g" | tee build.log
- echo "📦 当前缓存目录:"
- ls -la .gradle/
- echo "📦 Gradle 缓存结构检查"
- ls -la .gradle/caches/modules-2/files-2.1 || true
- echo "📦 缓存文件数量:$(find .gradle/caches/modules-2/files-2.1 -type f | wc -l)"
- echo "🛑 停止 Gradle 守护进程..."
- ./gradlew --stop
- echo "🔍 当前 Java 进程:"
- ps aux | grep java || true
tags:
- docker
- java
deploy:
stage: deploy
environment:
name: test
rules:
- if: '$CI_COMMIT_BRANCH == "test"'
script:
- echo "🛠️ 准备部署环境..."
- chmod +x ${COMPOSE_FILE} || true
- echo "🐳 当前 Docker 状态:"
- docker ps -a
- echo "🧹 停止并清理旧容器(包括孤儿容器)..."
- docker compose -p $PROJECT_NAME -f ${COMPOSE_FILE} down --remove-orphans
- echo "📥 拉取最新镜像..."
- docker compose -p $PROJECT_NAME -f ${COMPOSE_FILE} pull
- echo "🚀 启动新服务..."
- docker compose -p $PROJECT_NAME -f ${COMPOSE_FILE} up -d
- echo "✅ 当前服务状态:"
- docker compose -p $PROJECT_NAME -f ${COMPOSE_FILE} ps
- echo "🧼 清理悬空镜像..."
- docker image prune -f
tags:
- docker
- java