Skip to content

mousamdahal/golang-sample-webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Hello World Golang Web Server

This is a simple Golang web server that serves a "Hello, World!" message when you visit the root URL (/). The server is designed to be containerized using Docker.

Requirements

  • Docker

Usage

Running with Docker

  1. Build the Docker image:

    docker build -t hello-world-server .

  2. Run the Docker container:

    docker run -p 8080:8000 -e PORT=8080 hello-world-server

This command runs the hello-world-server container and maps the host's port 8080 to the container's port 8000. It also sets the PORT environment variable inside the container to 8080.

  1. Visit http://localhost:8080 in your web browser to see the "Hello, World!" message.

Configuration

The web server listens on the port specified by the PORT environment variable. If the PORT variable is not set, it defaults to 8000.

You can change the default port by setting the PORT environment variable when running the container.

Files

  • main.go: The Go source code that runs the web server.
  • Dockerfile: The Dockerfile used to build the Docker image.
  • README.md: This file, containing instructions and information about the project.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published