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

  1. Clone the Repository:

    git clone https://github.com/benhall/golang-demo.git
    cd golang-demo
    
  2. Build the Application:

    go build -o myapp
    

    This command uses the go build command to compile the Go code and create an executable file named myapp. The -o flag specifies the output filename.

Starting the Application

  1. Run the Application:
    ./myapp
    

Building and Running with Docker

  1. Build the Docker Image:

    docker build -t myapp .
    

    This command builds a Docker image named myapp from the Dockerfile in the current directory.

  2. 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.