My DockerFile is looking for .go
files in the wrong directory, it needs to be looking at the sub-directory called app
Here is my folder set up, parent folder is my-app
my-app/
├─ app/
│ ├─ api
│ ├─ go.mod
│ ├─ go.sum
│ ├─ main.go
DockerFile
DockerFile:
# syntax=docker/dockerfile:1
FROM golang:1.16-alpine
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o /docker-gs-ping
EXPOSE 8080
CMD [ "/docker-gs-ping" ]
As for now the DockerFile is looking for the go
files in the directory where DockerFile is, not in the app
sub-directory. Where can I fix that?
2
Answers
From what I understand it should be like this, basically copy everything to the app, run the download and build commands.
Here a possible solution building a lightweight docker image