From 042e135147c01c75569007214884a1a417b8383c Mon Sep 17 00:00:00 2001 From: Malte Reddig Date: Mon, 5 Oct 2020 13:38:38 +0200 Subject: [PATCH] Add Dockerfile and docker-compose.yml This provides a Dockerfile with an docker-compose.yml to install ifconfig.io on a Docker Server --- .dockerignore | 3 +++ Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d0781c3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +README.md +Dockerfile + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..26fb14a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM golang:alpine AS builder + +# Set necessary environmet variables needed for our image +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 + +# Move to working directory /build +WORKDIR /build + +# Copy and download dependency using go mod +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy the code into the container +COPY main.go . + +# Build the application +RUN go build -o main . + +# Move to /dist directory as the place for resulting binary folder +WORKDIR /dist + +# Copy binary from build to main folder +RUN cp /build/main . + +# Build a small image +FROM scratch AS production + +COPY --from=builder /dist/main / +COPY ./templates /templates +COPY ./LICENSE /LICENSE + +# Command to run +ENTRYPOINT ["/main"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7f13817 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.4" + +services: + ifconfig: + image: ifconfig.io:latest + build: + context: ./ + target: production + ports: + - ${PORT:-8080}:8080 + environment: + TLS: ${TLS:-0} + HOSTNAME: ${HOSTNAME}