fedect1 / graduation-project-fedect1

graduation-project-fedect1 created by GitHub Classroom
MIT License
1 stars 0 forks source link

#Setup Backend doesn't start without an .env file #10

Open Dr4gon opened 1 year ago

Dr4gon commented 1 year ago

@fedect1 I'm aware you shouldn't give out your "secrets" of mongodb. It's important to provide a Readme.md / setup that works out of the box. I'm doing the review with a beginners minds - I test everything as a new dev would. After the npm install this happens:

@Dr4gon ➜ /workspaces/graduation-project-fedect1/backend (main) $ docker-compose up backend
ERROR: Couldn't find env file: /workspaces/graduation-project-fedect1/backend/.env
Dr4gon commented 1 year ago

I fix the .env file in the backend and get the frontend error as well.

@Dr4gon ➜ /workspaces/graduation-project-fedect1/backend (main) $ docker-compose up backend
ERROR: Couldn't find env file: /workspaces/graduation-project-fedect1/frontend/.env
Dr4gon commented 1 year ago

It's running with 2 manually created .env files and the knowledge what needs to go in there.

@Dr4gon ➜ /workspaces/graduation-project-fedect1/backend (main) $ docker-compose up 
Building frontend

Two ideas:

  1. Put an .env file into your repos with the Constants and the local setting (which is hardly a secret)
  2. Build a script into your package.json that on npm install creates these files

Backend

MONGODB_CONNECTION_STRING=mongodb://mongo:27017

Frontend

VITE_API_BASE_URL=http://localhost:3000