Run the Project:
You have to make sure that you are in the same directory as the project. Then you can run the below script:
docker build -t {your-desired-image-name} .
docker run -d --env-file=.env --name {your-desired- container-name} -p {your-desired-port}:8080 {your-desired-image-name}
Note: Be careful with the port number. You can't run this project as a docker container while DB_HOST is set to 127.0.0.1 in .env file
Note: If you want to run the project as a docker container, you have to change the DB_HOST to the IP address of the container mentioned in the .env file. Refer here for the .env file.
You can get the IP address of the container by running the below command by replecing {your-container-name} with a container name you want to inspect
docker inspect --format '{{ .NetworkSettings.IPAddress }}' {your-container-name}
Example For docker inspect:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' postgres-cnt
Example for running docker container:
docker build -t project-rllc-img:1.0 .
docker run -d --env-file=.env --name project-rllc-cnt -p 8080:8080 project-rllc-img:1.0
Or you can run the project directly by running the below script from the same directory as the project:
go run main.go