I am having a weird issue to run a Go Echo Framework. It works fine when I use the docker run
command, that is no dependency issue and it executes the file properly but while running docker-compose up
it gives error:
Creating echo_app ... done
Attaching to echo_app
echo_app | server.go:6:2: cannot find package "github.com/labstack/echo/v4" in any of:
echo_app | /usr/local/go/src/github.com/labstack/echo/v4 (from $GOROOT)
echo_app | /go/src/github.com/labstack/echo/v4 (from $GOPATH)
echo_app exited with code 1
Below are my files:
Dockerfile
FROM golang:1.15-alpine
LABEL maintainer="Me"
RUN apk update
RUN apk add git
# Setting up Dev environment
RUN mkdir /echo_app
COPY . /echo_app/
WORKDIR /echo_app/
# Download Echo Framework with help of Go mod (Credit: https://github.com/labstack/echo/issues/1374#issuecomment-559990790)
# Init to create Go Module
RUN go mod init app.com/main
# Building to download echo framework and other dependencies
RUN go build
# RUN the server
#CMD go run server.go
EXPOSE 1323
docker-compose.yml
version: "3"
services:
web:
container_name: echo_app
image: echo_app:latest
build: ./
command: go run server.go
volumes:
- .:/echo_app
ports:
- "1323:1323"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…