I am trying to deploy my Golang application with the help of docker compose.
In CentOS server the hierarchy of folders:
docker_app
- src
- app
- docker-compose.yml
- main.go
This Golang application use several third-party libraries:
Gorilla Mux;
Gorilla Handlers;
pq;
godotenv;
GORM;
goracle.
docker-compose.yml:
version: '2'
services:
app:
image: golang:1.11-alpine
volumes:
- .:/go/src/app
working_dir: /go/src/app
command: go run main.go
When I try to run docker-compose up
project it raise error:
Attaching to app_app_1
app_1 | main.go:4:2: cannot find package "github.com/gorilla/handlers" in any of:
app_1 | /usr/local/go/src/github.com/gorilla/handlers (from $GOROOT)
app_1 | /go/src/github.com/gorilla/handlers (from $GOPATH)
As you can see I need to set up third-party libraries. How to make it correctly? Also how to set up the name of the future docker image and contaiener with the help of docker compose?
Is it possible to create go.mod
file on Windows 10
?
When I run $Env:GOOS = "linux"; $Env:GOARCH = "amd64"; go build
command in Powershell it raise error: