Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open ../.env: no such file or directory (Docker Image build) #236

Open
Ndeta100 opened this issue Aug 31, 2024 · 1 comment
Open

open ../.env: no such file or directory (Docker Image build) #236

Ndeta100 opened this issue Aug 31, 2024 · 1 comment

Comments

@Ndeta100
Copy link

Ndeta100 commented Aug 31, 2024

I get this error when I build and publish my docker image then I try to pull and run it locally or on a vm with coolify. I have added my env as github secrets for the builf process but I still get the same error, even after adding the env variables to coolify. It suggested I neeet to comment out godotenv.Load(), but still same issue. Anyone can help?

func init() { if err := godotenv.Load(); err != nil { log.Fatal(err) } }

@abuzaforfagun
Copy link

Probably you have placed the .env file in the wrong directory.
For an example, here is my file and folder structure:

│   .env
│   .env.test
│   go.mod
│   go.sum
│   readme.md
│   
├───cmd
│   ├───api
│   │       main.go

I have used the godotenv.Load(file_path) in the main.go file. Here is my code:
godotenv.Load("../../.env")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants