From 1a0b82287ac3cd8a2078504ef48b7e30ce7e9951 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 7 Aug 2019 08:01:59 +0200 Subject: [PATCH] Add dockerized version Signed-off-by: Knut Ahlers --- Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++ docker-entrypoint.sh | 6 ++++++ 2 files changed, 53 insertions(+) create mode 100644 Dockerfile create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d353db7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +FROM golang:alpine as builder + +ENV GO111MODULE=on + +COPY . /go/src/github.com/Luzifer/wiki +WORKDIR /go/src/github.com/Luzifer/wiki + +RUN set -ex \ + && apk add --update \ + curl \ + git \ + && go build \ + -ldflags "-X main.version=$(git describe --tags --always || echo dev)" \ + -mod=readonly \ + -o /go/bin/wiki + +RUN set -ex \ + && curl -sSfLo /usr/local/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64" \ + && curl -sSfLo /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64" \ + && chmod +x \ + /usr/local/bin/dumb-init \ + /usr/local/bin/gosu + +FROM alpine:latest + +ENV DATA_DIR=/data + +LABEL maintainer "Knut Ahlers " + +RUN set -ex \ + && apk --no-cache add \ + bash \ + ca-certificates \ + && adduser -D -h /home/wiki -S -u 1000 wiki + +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint +COPY --from=builder /go/bin/wiki /usr/local/bin/wiki +COPY --from=builder /usr/local/bin/dumb-init /usr/local/bin/dumb-init +COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu + +EXPOSE 3000 +VOLUME ["/data"] + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] +CMD ["--"] + +# vim: set ft=Dockerfile: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..93178b7 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/local/bin/dumb-init /bin/bash +set -euo pipefail + +chown wiki: "${DATA_DIR}" + +exec gosu wiki /usr/local/bin/wiki