D
D
Danya Kozlovskiy2021-10-16 22:53:49
go
Danya Kozlovskiy, 2021-10-16 22:53:49

Why does not see the config file in Docker?

Hi, using viper I take data from the config. Locally everything works fine, but when I run it in docker it can't find it.
Error: Config File \"local\" Not Found in \"[/configs]\"

Dockerfile:

FROM registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine as builder

WORKDIR /build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -o auth ./cmd/main.go


# generate clean, final image for end users
FROM quay.io/jitesoft/alpine:3.11.3
COPY --from=builder /build/auth /chupapimunyanya/
COPY --from=builder /build/configs /chupapimunyanya/configs/
COPY --from=builder /build/db /chupapimunyanya/db/
# executable
ENTRYPOINT [ "/chupapimunyanya/app/auth" ]


Vipers:
viper.AddConfigPath("configs")
  viper.SetConfigName("local")


Project structure:
auth/
--cmd/
----main.go
--configs/
----local.yml

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-10-16
@morto

Not strong in Go, but /configs is obviously the path from the root, but in fact the path is /chupapimunyanya/configs/
Go into the container ( docker exec -it имя_контейнера sh) and check if the files are placed correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question