-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
62 lines (56 loc) · 2.62 KB
/
docker-compose.yml
File metadata and controls
62 lines (56 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
######## app下api+rpc , Before starting this project, start the environment that the project depends on docker-compose-env.yml #######
services:
#前端网关nginx-gateay (只代理heart_trip,admin-api不在这里做代理)
# Front-end gateway nginx-gateway (Only agent heart_trip,admin-api Do not be an agent here)
nginx-gateway:
image: nginx:1.28
container_name: nginx-gateway
restart: always
# [安全建议] 除非明确知道需要,否则建议移除 privileged: true
# privileged: true
environment:
- TZ=Asia/Shanghai
ports:
- "8888:8081"
volumes:
- ./deploy/nginx/conf.d:/etc/nginx/conf.d
- ./data/nginx/log:/var/log/nginx
networks:
- heart_trip_net
depends_on:
- heart-trip
#前端api + 业务rpc - Front-end API + business RPC
heart-trip:
# 核心改动:不再使用旧的 'image',而是使用 'build' 指令
# Core change: No longer use the old 'image', but use the 'build' directive
build:
context: . # 指定 Dockerfile 的上下文路径,'.' 代表当前目录
dockerfile: Dockerfile # 指定用于构建的 Dockerfile 文件名 (假设您的文件名为 Dockerfile)
container_name: heart-trip
# 由于 GOPROXY 和 TZ 已经在 Dockerfile 中通过 ENV 设置,
# 这里的可以移除以避免冗余,除非您想在运行时覆盖它们。
# Since GOPROXY and TZ are already set via ENV in the Dockerfile,
# they can be removed here to avoid redundancy, unless you want to override them at runtime.
environment:
# - TZ=Asia/Shanghai # 已在 Dockerfile 中设置
# - GOPROXY: https://goproxy.cn,direct # 已在 Dockerfile 中设置
- OSS_ACCESS_KEY_ID=${OSS_ACCESS_KEY_ID}
- OSS_ACCESS_KEY_SECRET=${OSS_ACCESS_KEY_SECRET}
working_dir: /go/heart_trip # Dockerfile 中已设置 WORKDIR /go,这里可以改为 /go/heart_trip
volumes:
# 这里的 "." 相当于把整个项目挂载到 docker 中了, 前面是当前项目,后面是 docker 容器内
# 使用 docker 部署时需要额外注意,配置文件的路径不能当作在宿主机文件系统上的路径一样
- .:/go/heart_trip
# [安全建议] 这是一个非常高的权限,会带来安全风险。如果您的应用不是必须,请务必移除它。
# [Security Advice] This is a very high privilege and poses a security risk. Please remove it if not essential for your application.
# privileged: true
restart: always
networks:
- heart_trip_net
networks:
heart_trip_net:
external: true
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16