Skip to content

feat: added docker-compose and nginx configs#99

Merged
ayush00git merged 14 commits into
ayush00git:mainfrom
divyansh-v15-06:main
Jun 25, 2026
Merged

feat: added docker-compose and nginx configs#99
ayush00git merged 14 commits into
ayush00git:mainfrom
divyansh-v15-06:main

Conversation

@divyansh-v15-06

@divyansh-v15-06 divyansh-v15-06 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

This PR adds docker files and ngnix config to the service to make it docker image build ready and serve static files using nginx. This PR also adds deploy.yml CI script which triggers deployment to the server on committing to main branch.

Comment thread main.go
Comment thread config/db.go Outdated
@divyansh-v15-06

Copy link
Copy Markdown
Collaborator Author

"The reason we ignore the error is because log.Fatal() actually crashes and stops the server. It is not just a regular log print; log.Fatal calls os.Exit(1) under the hood.

In a Docker/production environment, we pass environment variables dynamically via Docker Compose or Kubernetes instead of copying a physical .env file into the container. Because there is no .env file in the container, godotenv.Load() will return an error.

If we don't ignore that error, the backend container will crash-loop on startup and fail to deploy. Using _ = godotenv.Load() ensures the app successfully boots up by reading the system environment variables when the physical .env file is absent."

@ayush00git

Copy link
Copy Markdown
Owner

"The reason we ignore the error is because log.Fatal() actually crashes and stops the server. It is not just a regular log print; log.Fatal calls os.Exit(1) under the hood.

In a Docker/production environment, we pass environment variables dynamically via Docker Compose or Kubernetes instead of copying a physical .env file into the container. Because there is no .env file in the container, godotenv.Load() will return an error.

If we don't ignore that error, the backend container will crash-loop on startup and fail to deploy. Using _ = godotenv.Load() ensures the app successfully boots up by reading the system environment variables when the physical .env file is absent."

Just keep a log.Print() for just logging purposes. It would help in production as well as in development

Comment thread app/nginx.conf
@ayush00git ayush00git changed the title changed /localhost to ports feat: added docker-compose and nginx configs Jun 25, 2026
@divyansh-v15-06

Copy link
Copy Markdown
Collaborator Author

@ayush00git "In our Docker network, cms-backend is indeed running internally on port 8080 (as defined by r.Run(":8080") in main.go).

Because the Nginx container (cms-frontend) and the Go container (cms-backend) are in the same Docker network, they talk to each other directly using their internal ports. So Nginx proxies requests internally to http://backend:8080 (where backend is the container name).

The only place we changed the port is on the host machine (exposing it as 8082:8080 in docker-compose.yml) to prevent conflicts with other services running on the server's port 8080. But internally inside the Docker network, Nginx must use 8080 to reach the backend."

@ayush00git ayush00git merged commit 03c2787 into ayush00git:main Jun 25, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants