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