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-demo
Build the Application:
go build -o myapp
This command uses the
go build
command to compile the Go code and create an executable file namedmyapp
. The-o
flag 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
myapp
from theDockerfile
in the current directory.Run the Docker Container:
docker run -p 8080:8080 myapp
This command runs a Docker container based on the
myapp
image 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:8080
in your web browser. - Docker: Access the application at
http://<Docker Host IP>:8080
in 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.