100DaysOfCode — Day 02

In day 2, I started creating a simple service and Dockerfile. See the code here https://github.com/MoatazBurhan/Grunderound. To test this code, install Docker first. Follow this document to instructions: https://docs.docker.com/get-started/.

Go Code

This code simply reads your URL path and display it in the browser.

package main

import (

func main() {

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "redirecting to link based on %q", html.EscapeString(r.URL.Path))

log.Fatal(http.ListenAndServe(":8081", nil))


FROM golang:1.15.8
RUN mkdir /app
ADD . /app
RUN go build -o main .
CMD ["/app/main"]

Deploying the Application

$ git clone https://github.com/MoatazBurhan/Grunderound
$ docker build -t go-service .
$ docker run -d -p 8080:8081 go-service

If you open up http://localhost:8080 within your browser, you should see that the application is successfully responding with redirecting to link based on "/".



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store