Jenkins file edit
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit
This commit is contained in:
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@@ -238,15 +238,15 @@ def deployToEnvironmentWithCompose(String env) {
|
|||||||
// 根据部署环境替换后端服务地址
|
// 根据部署环境替换后端服务地址
|
||||||
switch(env) {
|
switch(env) {
|
||||||
case 'dev':
|
case 'dev':
|
||||||
// 开发环境可能使用特定的后端服务地址
|
// 开发环境使用特定的后端服务地址
|
||||||
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'dev-backend-service:33333')
|
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'dev-backend-service:33333')
|
||||||
break
|
break
|
||||||
case 'staging':
|
case 'staging':
|
||||||
// 预发布环境可能使用特定的后端服务地址
|
// 预发布环境使用特定的后端服务地址
|
||||||
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'staging-backend-service:33333')
|
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'staging-backend-service:33333')
|
||||||
break
|
break
|
||||||
case 'prod':
|
case 'prod':
|
||||||
// 生产环境可能使用特定的后端服务地址
|
// 生产环境使用特定的后端服务地址
|
||||||
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'prod-backend-service:33333')
|
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'prod-backend-service:33333')
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@@ -257,9 +257,8 @@ def deployToEnvironmentWithCompose(String env) {
|
|||||||
// 写入环境特定的 nginx 配置
|
// 写入环境特定的 nginx 配置
|
||||||
writeFile file: "nginx-${env}.conf", text: nginxConfContent
|
writeFile file: "nginx-${env}.conf", text: nginxConfContent
|
||||||
|
|
||||||
// 创建 docker-compose.yml 文件,前端服务连接到已存在的后端
|
// 创建 docker-compose.yml 文件,使用卷挂载覆盖容器内的 nginx 配置
|
||||||
def composeFileContent = """version: '3.8'
|
def composeFileContent = """services:
|
||||||
services:
|
|
||||||
frontend:
|
frontend:
|
||||||
image: ${imageToDeploy}
|
image: ${imageToDeploy}
|
||||||
container_name: ${containerName}
|
container_name: ${containerName}
|
||||||
@@ -267,14 +266,14 @@ def deployToEnvironmentWithCompose(String env) {
|
|||||||
ports:
|
ports:
|
||||||
- "${getPortForEnvironment(env)}:80"
|
- "${getPortForEnvironment(env)}:80"
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway" # 兼容 Docker Desktop
|
- "host.docker.internal:host-gateway" # 允许访问宿主机
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app-network:
|
app-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
"""
|
"""
|
||||||
|
|
||||||
// 写入 docker-compose.yml 文件
|
// 写入 docker-compose.yml 文件
|
||||||
writeFile file: 'docker-compose.yml', text: composeFileContent
|
writeFile file: 'docker-compose.yml', text: composeFileContent
|
||||||
|
|||||||
Reference in New Issue
Block a user