带有Go模块导入的docker build问题

时间:2019-09-24 09:25:49

标签: docker go go-modules

我在使用特定项目结构使用Go构建微服务时遇到问题

研究后,我使用下面的项目结构

github.com/username/container/
├── pkg/ ('username' created packages - common for all services & reusable in other projects)
|   ├── errors/
|   ├── log/
|   ├── metrics/
|   ├── infra/     (sub category in packages)
|   |   ├── consul/
|   |   └── kubernetes/
|   └── tracing/
├── services/ (where all microservices will be imported as submodules - may or may not be reused)
|   ├── account/
|   |   ├── handler.go
|   |   ├── handler_test.go (unit testing, note filename with '_test')
|   |   ├── main.go
|   |   ├── main_test.go    (another unit testing)
|   |   ├── account.yml     (the configuration file for account microservice)
|   |   ├── submodule/      (sub directory)
|   |   |   ├── submodule.go
|   |   |   └── submodule_test.go   (submodule unit test)
|   |   ├── Dockerfile
|   |   └── README.md
|   ├── auth/
|   ├── booking/
|   └── user/
├── Makefile
├── README.md
└── docker-compose.yml

问题是当我建立帐户服务时,它给我一个错误(找不到模块github.com/user_name/services/pkg/errors)

那么当我的帐户服务具有Dockerfile和go.mod以外的依存关系时,如何构建我的帐户服务?

0 个答案:

没有答案