0

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 ***

  • You have several separate questions you've rolled into one here: (a) how to use Git commits; (b) how to use GitHub when using Git commits; and (c) how to organize your Docker setup. Decompose the three (and as always, search!). Note that the description you've given here for `git stash` is not quite right. I always advise Git newbies to *avoid* `git stash`, as it is (in my opinion) a bad / poorly-designed command, with a whole lot of traps for the unwary, and even a few for the wary. – torek Sep 17 '22 at 23:33

0 Answers0