diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9414382 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b893b1c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM golang:alpine as builder + +ENV GO111MODULE=on + +# Create the user and group files to run unprivileged +RUN mkdir /user && \ + echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \ + echo 'nobody:x:65534:' > /user/group + +RUN apk update && apk add --no-cache git ca-certificates tzdata sqlite build-base +RUN mkdir /build +COPY . /build/ +WORKDIR /build + +COPY ./ ./ +RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o bog . + +FROM golang:alpine AS final +LABEL author="Cajually " + +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=builder /user/group /user/passwd /etc/ +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /build/bog / +COPY --from=builder /build/default.toml / + +WORKDIR / + +USER nobody:nobody +ENTRYPOINT ["/bog"] + +EXPOSE 8002