Skip to content
Snippets Groups Projects
Unverified Commit 0394bf8c authored by Andrew Keesler's avatar Andrew Keesler
Browse files

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: default avatarAndrew Keesler <akeesler@vmware.com>
parent a672ff92
No related branches found
No related tags found
No related merge requests found
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 . . ...@@ -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 \ ...@@ -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 ...@@ -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/
......
...@@ -18,7 +18,7 @@ group=$(shell id -g -n) ...@@ -18,7 +18,7 @@ group=$(shell id -g -n)
export GOBIN=$(PWD)/bin export GOBIN=$(PWD)/bin
LD_FLAGS="-w -X main.version=$(VERSION)" LD_FLAGS="-w -X main.version=$(VERSION) -extldflags \"-static\""
# Dependency versions # Dependency versions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment