Skip to content

Commit

Permalink
docker-compose构建开发环境
Browse files Browse the repository at this point in the history
  • Loading branch information
gphper committed Jan 25, 2022
1 parent 1d0628e commit d624c7a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 460 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- [演示地址](#演示地址)

- [开始使用](#开始使用)
- [docker-compose构建环境](#docker-compose)
- [构建环境](#docker-compose)
- [项目目录](#结构)
- [分页](#分页)
- [日志](#日志)
Expand Down Expand Up @@ -96,7 +96,7 @@

4. 运行 `go run .\cmd\ginadmin`访问地址 http://localhost:端口地址/admin/login。默认账户:admin 密码:111111

### :small_blue_diamond:<a name="docker-compose">docker-compose构建环境</a>
### :small_blue_diamond:<a name="docker-compose">构建开发环境</a>

1. 替换conf目录下的配置项

Expand All @@ -121,7 +121,30 @@
password=ginadmin
```

2. 执行命令 docker-compose up
2. 执行命令 `docker-compose up`

3. 进入到容器中 `docker exec -it ginadmin-web bash`

4. 下载扩展 `go mod tidy`

5. 运行项目 ` go run ./cmd/ginadmin/` 访问地址 `http://localhost:20010/admin/login`

6. 桌面连接redis地址

```
地址:127.0.0.1
端口:6380
密码:ginadmin
```

7. 桌面连接mysql地址

```
地址:localhost
端口:3310
用户名:docker
密码:123456
```

### :small_blue_diamond:<a name="结构">项目目录</a>

Expand Down
9 changes: 3 additions & 6 deletions build/DockerfileWeb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM golang
MAINTAINER gphper
COPY . /$GOPATH/src/ginadmin/
WORKDIR /$GOPATH/src/ginadmin/
WORKDIR /home/ginadmin/
RUN go env -w GO111MODULE=on && \
go env -w GOPROXY=https://goproxy.cn,direct && \
go mod tidy && \
go build ./cmd/ginadmin
go env -w GOPROXY=https://goproxy.cn,direct
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
EXPOSE 20010
ENTRYPOINT ["./ginadmin"]
CMD ["top","-b"]
5 changes: 4 additions & 1 deletion deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ services:
volumes:
- .\mysqldata:/var/lib/mysql
- .\conf\mysql\my.cnf:/etc/mysql/my.cnf
ports:
- "3310:3306"
web:
container_name: ginadmin-web
image: ginadmin-web
build:
context: ..
dockerfile: build/DockerfileWeb
volumes:
- ..\:/home/ginadmin
ports:
- 20010:20010
depends_on:
Expand All @@ -35,4 +39,3 @@ services:
links:
- mysql:localmysql
- redis:localredis
restart: always
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/casbin/casbin/v2 v2.31.2 // direct
github.com/casbin/gorm-adapter/v3 v3.2.12
github.com/gin-contrib/gzip v0.0.3 // indirect
github.com/gin-contrib/gzip v0.0.3
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.0
github.com/go-openapi/jsonreference v0.19.6 // indirect
Expand All @@ -16,16 +16,18 @@ require (
github.com/go-playground/universal-translator v0.17.0
github.com/go-playground/validator/v10 v10.7.0
github.com/go-redis/redis v6.15.9+incompatible
github.com/golang/mock v1.5.0 // indirect
github.com/gphper/multitemplate v0.1.0
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/strftime v1.0.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mojocn/base64Captcha v1.3.5 // indirect
github.com/mojocn/base64Captcha v1.3.5
github.com/onsi/gomega v1.16.0 // indirect
github.com/robfig/cron v1.2.0
github.com/spf13/cobra v1.2.1
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.0
github.com/ugorji/go v1.2.4 // indirect
Expand Down
Loading

0 comments on commit d624c7a

Please sign in to comment.