Skip to content

Commit b3690e8

Browse files
feat: docker-compose-test network bridge
1 parent 5b0db92 commit b3690e8

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed
Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# services:
2+
# nest-app:
3+
# build:
4+
# context: ./
5+
# dockerfile: ./Dockerfile
6+
# depends_on:
7+
# - mysql-container
8+
# - redis-container
9+
# ports:
10+
# - '3000:3000'
11+
# mysql-container:
12+
# image: mysql
13+
# ports:
14+
# - '3306:3306'
15+
# volumes:
16+
# - /Users/guang/mysql-data:/var/lib/mysql
17+
# redis-container:
18+
# image: redis
19+
# ports:
20+
# - '6379:6379'
21+
# volumes:
22+
# - /Users/guang/aaa:/data
23+
version: '3.8'
124
services:
225
nest-app:
326
build:
@@ -8,15 +31,20 @@ services:
831
- redis-container
932
ports:
1033
- '3000:3000'
34+
networks:
35+
- common-network
1136
mysql-container:
1237
image: mysql
13-
ports:
14-
- '3306:3306'
1538
volumes:
1639
- /Users/guang/mysql-data:/var/lib/mysql
40+
networks:
41+
- common-network
1742
redis-container:
1843
image: redis
19-
ports:
20-
- '6379:6379'
2144
volumes:
2245
- /Users/guang/aaa:/data
46+
networks:
47+
- common-network
48+
networks:
49+
common-network:
50+
driver: bridge

docker-compose-test/src/app.module.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { AppService } from './app.service';
99
imports: [
1010
TypeOrmModule.forRoot({
1111
type: "mysql",
12-
host: "localhost",
12+
// host: "localhost",
13+
// host: '192.168.1.6',
14+
host: "mysql-container",
1315
port: 3306,
1416
username: "root",
1517
password: "guang",
@@ -31,7 +33,9 @@ import { AppService } from './app.service';
3133
async useFactory() {
3234
const client = createClient({
3335
socket: {
34-
host: 'localhost',
36+
// host: 'localhost',
37+
// host: '192.168.1.6',
38+
host: 'redis-container',
3539
port: 6379
3640
}
3741
});
@@ -42,3 +46,4 @@ import { AppService } from './app.service';
4246
]
4347
})
4448
export class AppModule {}
49+

0 commit comments

Comments
 (0)