skip to Main Content

I am trying to import my firebase config file into my golang application like so

configfile := "internal/pkg/utils/firebase/firebaseConfig.json"
opt := option.WithCredentialsFile(configFile)

However, I keep running into this error when I run my application inside Docker:

"open "internal/pkg/utils/firebase/firebaseConfig.json": no such file or directory". 

When I compile on my machine and run it, it works perfectly fine. The file is located and my authentication client is initialized. I tried going inside the docker container to make sure that my file exists at /app/internal/pkg/utils/firebase/ and it does.

Here is my Dockerfile:

FROM golang:1.22

WORKDIR /app

COPY go.mod go.sum ./ 
RUN go mod download && go mod verify

COPY . .

RUN go build -o ./bin/tamra ./cmd/tamra/

# Command to run the executable
CMD ["./bin/tamra", "-port=8080", "-db=postgres://postgres:mysecretpassword@db:5432/tamra-postgis?sslmode=disable", "-log-level=debug", "-firebase-config=internal/pkg/utils/firebase/firebaseConfig.json"]

2

Answers


  1. Assuming that your project is laid out like this (missing many files that you might have):

    ├── Dockerfile
    └── internal
        └── pkg
            └── utils
                └── firebase
                    └── firebaseConfig.json
    

    I can confirm that the file is where you would expect it to be on the container.

    So this leads me to suspect that there is something in your Go code which is causing the problem. Can you share a stripped down version of your application that demonstrates this issue?

    Login or Signup to reply.
  2. Look once inside the container all in all you are in new world of container Operating System.

    try with absolute path.

    -firebase-config=/app/internal/pkg/utils/firebase/firebaseConfig.json

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search