I’m trying to write a very simple and straightforward docker file for a Golang application. But for some reason it is giving me this error when trying to run the image:
exec /app/serverTest: no such file or directory
I can’t figure out what is wrong with it, searched for similar questions but no luck solving the issue.
Here’s my dockerfile:
## Build
FROM golang:1.20 AS build
WORKDIR /tmp/build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go build -o ./out/serverTest .
## Deploy
FROM golang:alpine
COPY --from=build /tmp/build/out/serverTest /app/serverTest
EXPOSE 8080
ENTRYPOINT ["/app/serverTest"]
I’ve tried giving +x permissions, using CMD instead of ENTRYPOINT, changing names/folders, among other things..
Some idea on what the problem could be?
2
Answers
Seems like the executable file wont run with alpine. Dunno why, but if I change golang:alpine to debian:latest, it works
Try to build with: