Skip to content

Instantly share code, notes, and snippets.

@kainlite
Created May 1, 2019 17:06
Show Gist options
  • Select an option

  • Save kainlite/5db561f6f8808f1b5eaf091887416311 to your computer and use it in GitHub Desktop.

Select an option

Save kainlite/5db561f6f8808f1b5eaf091887416311 to your computer and use it in GitHub Desktop.
whatismyip-go
FROM golang:1.12-alpine
LABEL maintainer="kainlite@gmail.com"
# Set the Current Working Directory inside the container
WORKDIR $GOPATH/src/github.com/kainlite/whatismyip-go
COPY . .
# Download all the dependencies
# https://stackoverflow.com/questions/28031603/what-do-three-dots-mean-in-go-command-line-invocations
RUN go get -d -v ./...
# Install the package and create test binary
RUN go install -v ./... && \
CGO_ENABLED=0 GOOS=linux go test -c
# This container exposes port 8080 to the outside world
EXPOSE 8000
# Set default environment variable values
ENV WHATISMYIP_PORT 8000
# Perform any further action as an unprivileged user.
USER nobody:nobody
# Run the executable
CMD ["whatismyip-go"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment