Skip to content

Commit 25e2578

Browse files
authored
Merge pull request #41 from AllenShen/feature/add_dockerfile
add dockerfile of dex
2 parents 492ba0e + 132f296 commit 25e2578

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

Dockerfile-muiti-architecture

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
FROM golang:1.16.6-alpine3.13 AS builder
2+
3+
WORKDIR /usr/local/src/dex
4+
5+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
6+
RUN apk add --no-cache --update alpine-sdk
7+
8+
ARG TARGETOS
9+
ARG TARGETARCH
10+
ARG TARGETVARIANT=""
11+
12+
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT}
13+
ENV GOPROXY=https://goproxy.cn,direct
14+
15+
COPY go.mod go.sum ./
16+
COPY api/v2/go.mod api/v2/go.sum ./api/v2/
17+
RUN go mod download
18+
19+
COPY . .
20+
21+
RUN make release-binary
22+
23+
FROM alpine:3.14.0 AS gomplate
24+
25+
ARG TARGETOS
26+
ARG TARGETARCH
27+
ARG TARGETVARIANT
28+
29+
ENV GOMPLATE_VERSION=v3.9.0
30+
31+
RUN wget -O /usr/local/bin/gomplate-amd64 \
32+
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_linux-amd64" \
33+
&& chmod +x /usr/local/bin/gomplate-amd64
34+
35+
RUN wget -O /usr/local/bin/gomplate-arm64 \
36+
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_linux-arm64" \
37+
&& chmod +x /usr/local/bin/gomplate-arm64
38+
39+
FROM alpine:3.14.0
40+
41+
ARG TARGETARCH
42+
43+
# Dex connectors, such as GitHub and Google logins require root certificates.
44+
# Proper installations should manage those certificates, but it's a bad user
45+
# experience when this doesn't work out of the box.
46+
#
47+
# OpenSSL is required so wget can query HTTPS endpoints for health checking.
48+
RUN apk add --no-cache --update ca-certificates openssl
49+
50+
RUN mkdir -p /var/dex
51+
RUN chown -R 1001:1001 /var/dex
52+
53+
RUN mkdir -p /etc/dex
54+
COPY config.docker.yaml /etc/dex/
55+
RUN chown -R 1001:1001 /etc/dex
56+
57+
# Copy module files for CVE scanning / dependency analysis.
58+
COPY --from=builder /usr/local/src/dex/go.mod /usr/local/src/dex/go.sum /usr/local/src/dex/
59+
COPY --from=builder /usr/local/src/dex/api/v2/go.mod /usr/local/src/dex/api/v2/go.sum /usr/local/src/dex/api/v2/
60+
61+
COPY --from=builder /go/bin/dex /usr/local/bin/dex
62+
COPY --from=builder /usr/local/src/dex/web /srv/dex/web
63+
64+
COPY --from=gomplate /usr/local/bin/gomplate-${TARGETARCH} /usr/local/bin/gomplate
65+
66+
USER 1001:1001
67+
68+
COPY docker-entrypoint.sh /entrypoint.sh
69+
70+
ENV DEX_FRONTEND_DIR=/srv/dex/custom-web
71+
72+
COPY --chown=root:root custom-web /srv/dex/custom-web
73+
74+
ENTRYPOINT ["/entrypoint.sh"]
75+
CMD ["dex", "serve", "/etc/dex/config.docker.yaml"]

0 commit comments

Comments
 (0)