feat: added docker-compose and nginx configs#99
Conversation
|
"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 |
|
@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." |
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.