2

When I use multi stage in Docker, it cannot find the container config file, but when I use only the first stage, the container works fine. I need this as I'm going to reduce the size for the deployment phase, but I couldn't find a solution. I have no problem reading the config file in my local. Here is my docker file

FROM golang:1.18.3-alpine AS builder

WORKDIR /app/policy-manangement-service
ENV GO111MODULE=on
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /policy-manangement-service ./cmd/policy-management

FROM alpine:latest
COPY --from=builder /policy-manangement-service ./
ENTRYPOINT ["./policy-manangement-service"]

and my error:

{"app-name":"policy-management-service","error":"Config File \"local\" Not Found in \"[/configs]\"","level":"fatal","message":"Error while reading configs","time":"2022-07-12T14:27:58.486529597Z"}

my project structure:

cmd
- policy-manangement
-- main
configs 
- local.yaml
internal
Mert Özler
  • 113
  • 5
  • 2
    The final image only `COPY --from=builder` the compiled binary, but nothing else. If you need the config file in the image as well, it also needs to be `COPY`ed. – David Maze Jul 12 '22 at 14:34
  • I can't believe I didn't see this... After copying it as you said, my problem was solved, thank you :) – Mert Özler Jul 12 '22 at 14:48

0 Answers0