I have created two (2) NestJS projects using Visual Studio Code, that are 99.9% identical, on 2 distinct host machines. Each project relies upon a docker-compose.yaml file and a separate .env file to connect to a Postgres database. The issue is that on one host machine I successfully use the default port (5432). However, on another host machine, I am unable to use the Postgres default port, and so changed the port value to 5433. The project on each machine runs successfully without issue(s).
My question is how I keep the local project settings in the .env file and the docker-compose.yaml without committing to Github?
I modified .gitignore to include both files. Git expects me to commit my newest changes, which is only the port number (5432 <--> 5433). And of now .gitignore is also a change. I am expected to commit these three (3) changed files to GitHub.
I have also tried 'git stash', which, according to GitHub specs, rollbacks to the HEAD of last commit. Which just undoes my changes. Committing to GitHub means that 'git pull' will be necessary on 2nd host, and so the port number must be modified to expected value. This is a cycle that I have been unable to get past. Git stash command does not appear to provide any options that I can use to resolve. I did mention that I am using a docker container which I start with the compose YAML file.
I am seeking help to resolve. I am including the relevant code.
docker-compose.yaml ports:
- 5432:5434 **** On 2nd host ports - 5433:5435 *** environment: POSTGRES_USER: postgres
.env file DATABASE_URL="postgresql://postgres:XXXXxxx@localhost:5432/nest?schema=public" *** On 2nd host port set to 5433 ***