From 21b9343534e2f03f4bfe2466cc8638abe5a43df9 Mon Sep 17 00:00:00 2001 From: nhyatt Date: Sat, 20 Jan 2024 10:50:03 -0600 Subject: [PATCH] Adds Dockerfile --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b3b8070 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Step 1 - Build Container +#### +FROM golang:alpine AS builder + +COPY . /go/src/app + +WORKDIR /go/src/app + +RUN apk add --no-cache git && \ + git config --global --add safe.directory /go/src/app && \ + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -ldflags="-s -w" -tags timetzdata -o ifire ./ + +# Step 2 - Running Container +#### +FROM alpine:latest + +LABEL org.opencontainers.image.title="Is the internet on fire?" + +RUN addgroup -S -g 1000 app && \ + adduser --disabled-password -G app --gecos "application account" --home "/home/app" --shell "/sbin/nologin" --uid 1000 app && \ + apk add --no-cache bind-tools +COPY --from=builder --chown=app:app /go/src/app/ifire /usr/local/bin/ifire + +USER app:app +WORKDIR /home/app + +ENTRYPOINT ["/bin/sh", "-c", "ifire"]