-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use multi-stage build to reduce image size
Signed-off-by: Knut Ahlers <knut@ahlers.me>
- Loading branch information
Showing
2 changed files
with
30 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
EXPOSE 8082 | ||
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters