From cb18a5f42acd548bcb48c6fb950eb87d18fd0fab Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Dec 2019 07:33:24 +0100 Subject: [PATCH] Docker build script --- Dockerfile | 18 ++++++++++++++++++ contrib/etc_group | 1 + contrib/etc_passwd | 1 + 3 files changed, 20 insertions(+) create mode 100644 Dockerfile create mode 100644 contrib/etc_group create mode 100644 contrib/etc_passwd diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..54d3872 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.13 AS builder +COPY . /app +WORKDIR /app +RUN go generate +RUN \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOPROXY=https://proxy.golang.org,direct \ + go build -o main main.go + +FROM scratch +COPY contrib/etc_group /etc/group +COPY contrib/etc_passwd /etc/passwd +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /app/main /main +USER user +ENTRYPOINT ["/main"] +CMD ["server"] \ No newline at end of file diff --git a/contrib/etc_group b/contrib/etc_group new file mode 100644 index 0000000..3ea3d13 --- /dev/null +++ b/contrib/etc_group @@ -0,0 +1 @@ +nogroup:x:65534: \ No newline at end of file diff --git a/contrib/etc_passwd b/contrib/etc_passwd new file mode 100644 index 0000000..a557309 --- /dev/null +++ b/contrib/etc_passwd @@ -0,0 +1 @@ +user:!x:33:33:nogroup:/var/www:/usr/sbin/nologin \ No newline at end of file