I try to build the go app as follow, my main.go file is at cmd/app/main.go.
However, when I try running docker build --no-cache .
and docker run <container_id>
.
It gives me exec ./bin/app: no such file or directory
I've already test that running go build -o ./bin/app ./cmd/app
and ./bin/app
is able to run correctly.
Here is my Dockerfile
# Build phase
FROM golang:1.20 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -o ./bin/app ./cmd/app
# Production phase
FROM alpine:3.14
WORKDIR /app
COPY --from=builder /app/bin/app ./bin/app
ENTRYPOINT [ "./bin/app" ]
I tried to access into the container docker run -it -t fyno/server/multi /bin/sh
/app # cd bin
/app/bin # ls -la
total 11636
drwxr-xr-x 2 root root 4096 Apr 12 05:04 .
drwxr-xr-x 1 root root 4096 Apr 12 05:04 ..
-rwxr-xr-x 1 root root 11904381 Apr 12 05:04 app
/app/bin # ./app
/bin/sh: ./app: not found
/app/bin #
Thanks.
how to fix the problem?