mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-20 12:51:17 +00:00
Use multi-stage build to reduce image size
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
773a88c5ba
commit
a272b49cf8
2 changed files with 30 additions and 17 deletions
31
Dockerfile
31
Dockerfile
|
@ -1,22 +1,35 @@
|
|||
FROM golang:alpine
|
||||
|
||||
LABEL maintainer "Knut Ahlers <knut@ahlers.me>"
|
||||
FROM golang:alpine as builder
|
||||
|
||||
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)" \
|
||||
&& apk add --update git \
|
||||
&& go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)"
|
||||
|
||||
FROM alpine:3.8
|
||||
|
||||
LABEL maintainer "Knut Ahlers <knut@ahlers.me>"
|
||||
|
||||
RUN set -ex \
|
||||
&& apk --no-cache add \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
&& 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
|
||||
&& apk --no-cache del --purge \
|
||||
curl
|
||||
|
||||
COPY --from=builder /go/bin/nginx-sso /usr/local/bin/
|
||||
COPY --from=builder /go/src/github.com/Luzifer/nginx-sso/config.yaml /usr/local/share/nginx-sso/
|
||||
COPY --from=builder /go/src/github.com/Luzifer/nginx-sso/docker-start.sh /usr/local/bin/
|
||||
COPY --from=builder /go/src/github.com/Luzifer/nginx-sso/frontend/* /usr/local/share/nginx-sso/frontend/
|
||||
|
||||
EXPOSE 8082
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
ADD docker-start.sh /usr/local/bin
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/docker-start.sh"]
|
||||
CMD ["--"]
|
||||
|
||||
# vim: set ft=Dockerfile:
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
set -euo pipefail
|
||||
|
||||
# Copy frontend if not available
|
||||
[ -d /data/frontend ] || cp -r /go/src/github.com/Luzifer/nginx-sso/frontend /data/frontend
|
||||
[ -d /data/frontend ] || cp -r /usr/local/share/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
|
||||
cp /usr/local/share/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 \
|
||||
$@
|
||||
exec /usr/local/bin/nginx-sso \
|
||||
--config /data/config.yaml \
|
||||
--frontend-dir /data/frontend \
|
||||
$@
|
||||
|
|
Loading…
Reference in a new issue