Skip to content

Instantly share code, notes, and snippets.

@andressamachado
Last active November 17, 2021 05:45
Show Gist options
  • Save andressamachado/0497d6fceaf341316f8afb32320f65d0 to your computer and use it in GitHub Desktop.
Save andressamachado/0497d6fceaf341316f8afb32320f65d0 to your computer and use it in GitHub Desktop.
# syntax=docker/dockerfile:1
# Defining the base image layer from which the container will be build, in our case golang as we are using Go to setup the server.
# I got image from Docker hub Official Images webpage. https://hub.docker.com/_/golang
FROM golang:1.16.10-alpine
# Default port value
ARG GO_SERVER_PORT=3030
# Creating a default directory to live inside the container
WORKDIR /go-web-server
# Copying root dependencies file provided (module) into the app directory within the image
COPY go.mod ./
RUN go mod download
# Copying our source code into the app directory within the image and build it
COPY main.go ./
RUN go build -o /go-web-server
EXPOSE ${GO_SERVER_PORT}
CMD [ "/go-web-server/go-web-server" ]
@andressamachado
Copy link
Author

Hi Kim!

I wrote some comments to show my thoughts during the process. I did not know if I should write them as I saw on the directions to write the Dockerfile as if the container would be used in production. Hope it is okay :)

Screen Shot 2021-11-17 at 12 16 42 AM

Screen Shot 2021-11-17 at 12 17 46 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment