distroless: Dockerfile works with distroless base image
I can build this via: docker build --build-arg BASEIMAGE=gcr.io/distroless/static:latest -t andrew:distroless . Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
parent
a672ff9288
commit
0394bf8cea
18
Dockerfile
18
Dockerfile
@ -1,3 +1,5 @@
|
|||||||
|
ARG BASEIMAGE=alpine:3.15.0
|
||||||
|
|
||||||
FROM golang:1.17.6-alpine3.14 AS builder
|
FROM golang:1.17.6-alpine3.14 AS builder
|
||||||
|
|
||||||
WORKDIR /usr/local/src/dex
|
WORKDIR /usr/local/src/dex
|
||||||
@ -20,6 +22,12 @@ COPY . .
|
|||||||
|
|
||||||
RUN make release-binary
|
RUN make release-binary
|
||||||
|
|
||||||
|
FROM alpine:3.15.0 AS stager
|
||||||
|
|
||||||
|
RUN mkdir -p /var/dex
|
||||||
|
RUN mkdir -p /etc/dex
|
||||||
|
COPY config.docker.yaml /etc/dex/
|
||||||
|
|
||||||
FROM alpine:3.15.0 AS gomplate
|
FROM alpine:3.15.0 AS gomplate
|
||||||
|
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
@ -33,7 +41,7 @@ RUN wget -O /usr/local/bin/gomplate \
|
|||||||
&& chmod +x /usr/local/bin/gomplate
|
&& chmod +x /usr/local/bin/gomplate
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.15.0
|
FROM $BASEIMAGE
|
||||||
|
|
||||||
# Dex connectors, such as GitHub and Google logins require root certificates.
|
# Dex connectors, such as GitHub and Google logins require root certificates.
|
||||||
# Proper installations should manage those certificates, but it's a bad user
|
# Proper installations should manage those certificates, but it's a bad user
|
||||||
@ -42,12 +50,8 @@ FROM alpine:3.15.0
|
|||||||
# See https://go.dev/src/crypto/x509/root_linux.go for Go root CA bundle locations.
|
# See https://go.dev/src/crypto/x509/root_linux.go for Go root CA bundle locations.
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
RUN mkdir -p /var/dex
|
COPY --from=stager --chown=1001:1001 /var/dex /var/dex
|
||||||
RUN chown -R 1001:1001 /var/dex
|
COPY --from=stager --chown=1001:1001 /etc/dex /etc/dex
|
||||||
|
|
||||||
RUN mkdir -p /etc/dex
|
|
||||||
COPY config.docker.yaml /etc/dex/
|
|
||||||
RUN chown -R 1001:1001 /etc/dex
|
|
||||||
|
|
||||||
# Copy module files for CVE scanning / dependency analysis.
|
# Copy module files for CVE scanning / dependency analysis.
|
||||||
COPY --from=builder /usr/local/src/dex/go.mod /usr/local/src/dex/go.sum /usr/local/src/dex/
|
COPY --from=builder /usr/local/src/dex/go.mod /usr/local/src/dex/go.sum /usr/local/src/dex/
|
||||||
|
Reference in New Issue
Block a user