Building and Starting the benhall/golang-demo Project
This documentation outlines the steps required to build and start the benhall/golang-demo project.
Prerequisites
- Go installed and configured on your system.
- Docker installed and configured on your system.
Building the Project
Clone the Repository:
git clone https://github.com/benhall/golang-demo.git cd golang-demoBuild the Application:
go build -o myappThis command uses the
go buildcommand to compile the Go code and create an executable file namedmyapp. The-oflag specifies the output filename.
Starting the Application
- Run the Application:
./myapp
Building and Running with Docker
Build the Docker Image:
docker build -t myapp .This command builds a Docker image named
myappfrom theDockerfilein the current directory.Run the Docker Container:
docker run -p 8080:8080 myappThis command runs a Docker container based on the
myappimage and maps port 8080 on the host machine to port 8080 inside the container.
Accessing the Application
After successfully building and running the application, you can access it via:
- Locally: Access the application at
http://localhost:8080in your web browser. - Docker: Access the application at
http://<Docker Host IP>:8080in your web browser.
Note: You may need to replace <Docker Host IP> with the actual IP address of your Docker host machine.
Conclusion
Following these steps will allow you to build and start the benhall/golang-demo project.