docker database use volumes

This commit is contained in:
viletyy 2019-08-04 22:37:27 +08:00
parent 28c9a98dd0
commit a80763de35
2 changed files with 5 additions and 4 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ conf/app.ini
.idea/* .idea/*
main main
runtime/* runtime/*
data/docker-postgres/*

View File

@ -9,12 +9,12 @@ game_demo/
└── runtime # 应用运行时数据 └── runtime # 应用运行时数据
``` ```
### Run Server ### Run Server By Docker
#### Before #### Before
cp app.ini.local app.ini cp app.ini.local app.ini
mkdir -p data/docker-postgres
```shell script ```shell script
docker run --name postgres -p 5433:5432 -e POSTGRES_PASSWORD=123456 -d postgres docker run --name postgres -p 5433:5432 -e POSTGRES_PASSWORD=123456 -v $GOPATH/src/game_demo/data/docker-postgres:/var/lib/postgresql/data -d postgres
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
docker build -t game_demo_scratch . docker build -t game_demo_scratch .
docker run --link postgres:postgres -p 8000:8000 game_demo_scratch docker run --link postgres:postgres -p 8000:8000 game_demo_scratch