fix: 容器内流量转发

This commit is contained in:
Tim
2025-09-29 18:08:35 +08:00
parent 201af061e4
commit e9878487e8
2 changed files with 54 additions and 7 deletions

View File

@@ -81,8 +81,7 @@ LOG_LEVEL=INFO
# === Frontend (Nuxt) ===
NUXT_PUBLIC_API_BASE_URL=http://localhost:8080
NUXT_PUBLIC_API_BASE_URL_SSR=http://springboot:8080
NUXT_PUBLIC_WEBSOCKET_URL=http://websocket_service:8082
NUXT_PUBLIC_WEBSOCKET_URL=http://localhost:8082
NUXT_PUBLIC_WEBSITE_BASE_URL=http://localhost:3000
# 线上 & 本地均可使用
NUXT_PUBLIC_GOOGLE_CLIENT_ID=777830451304-nt8afkkap18gui4f9entcha99unal744.apps.googleusercontent.com

View File

@@ -14,7 +14,17 @@ services:
networks:
- openisle-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-p$MYSQL_ROOT_PASSWORD"]
test:
[
"CMD",
"mysqladmin",
"ping",
"-h",
"127.0.0.1",
"-u",
"root",
"-p$MYSQL_ROOT_PASSWORD",
]
interval: 5s
timeout: 3s
retries: 30
@@ -36,7 +46,7 @@ services:
- cluster.blocks.create_index=false
ulimits:
memlock: { soft: -1, hard: -1 }
nofile: { soft: 65536, hard: 65536 }
nofile: { soft: 65536, hard: 65536 }
volumes:
- ./data:/usr/share/opensearch/data
- ./snapshots:/snapshots
@@ -45,7 +55,11 @@ services:
- "${OPENSEARCH_METRICS_PORT:-9600}:9600"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:9200/_cluster/health >/dev/null"]
test:
[
"CMD-SHELL",
"curl -fsS http://127.0.0.1:9200/_cluster/health >/dev/null",
]
interval: 10s
timeout: 5s
retries: 30
@@ -65,7 +79,7 @@ services:
- opensearch
restart: unless-stopped
networks:
- openisle-network
- openisle-network
rabbitmq:
image: rabbitmq:3.13-management
@@ -90,7 +104,6 @@ services:
networks:
- openisle-network
redis:
image: redis:7
container_name: openisle-redis
@@ -219,6 +232,41 @@ services:
profiles:
- service
loopback_8080:
image: alpine/socat
container_name: loopback-8080
# 监听“frontend_dev 容器自身的” 127.0.0.1:8080 → 转发到 springboot:8080
command: ["-d","-d","-ly","TCP4-LISTEN:8080,bind=127.0.0.1,reuseaddr,fork","TCP4:springboot:8080"]
depends_on:
springboot:
condition: service_started
network_mode: "service:frontend_dev"
profiles: ["dev"]
healthcheck:
test: ["CMD","sh","-c","nc -z 127.0.0.1 8080"]
interval: 5s
timeout: 3s
retries: 20
start_period: 10s
loopback_8082:
image: alpine/socat
container_name: loopback-8082
# 监听 127.0.0.1:8082 → 转发到 websocket-service:8082WS 纯 TCP 可直接过)
command: ["-d","-d","-ly","TCP4-LISTEN:8082,bind=127.0.0.1,reuseaddr,fork","TCP4:websocket-service:8082"]
depends_on:
websocket-service:
condition: service_started
network_mode: "service:frontend_dev"
profiles: ["dev"]
healthcheck:
test: ["CMD","sh","-c","nc -z 127.0.0.1 8082"]
interval: 5s
timeout: 3s
retries: 20
start_period: 10s
networks:
openisle-network:
driver: bridge