From daa85d501694c4aa3e7447ed596ed8507b7b550e Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 28 Jan 2018 18:43:58 +0100 Subject: [PATCH] Add dockerized version Signed-off-by: Knut Ahlers --- Dockerfile | 22 ++++++++++++++++++++++ docker-start.sh | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Dockerfile create mode 100755 docker-start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eb29964 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:alpine + +LABEL maintainer "Knut Ahlers " + +ADD . /go/src/github.com/Luzifer/nginx-sso +WORKDIR /go/src/github.com/Luzifer/nginx-sso + +RUN set -ex \ + && apk --no-cache add git ca-certificates bash curl \ + && go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)" \ + && curl -sSfLo /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 \ + && chmod +x /usr/local/bin/dumb-init \ + && apk --no-cache del --purge git curl + +EXPOSE 8082 + +VOLUME ["/data"] + +ADD docker-start.sh /usr/local/bin + +ENTRYPOINT ["/usr/local/bin/docker-start.sh"] +CMD ["--"] diff --git a/docker-start.sh b/docker-start.sh new file mode 100755 index 0000000..86507fb --- /dev/null +++ b/docker-start.sh @@ -0,0 +1,17 @@ +#!/usr/local/bin/dumb-init /bin/bash +set -euo pipefail + +# Copy frontend if not available +[ -d /data/frontend ] || cp -r /go/src/github.com/Luzifer/nginx-sso/frontend /data/frontend + +[ -e /data/config.yaml ] || { + cp /go/src/github.com/Luzifer/nginx-sso/config.yaml /data/config.yaml + echo "An example configuration was copied to /data/config.yaml - You want to edit that one!" + exit 1 +} + +echo "Starting nginx-sso" +exec /go/bin/nginx-sso \ + --config /data/config.yaml \ + --frontend-dir /data/frontend \ + $@