-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
91 lines (60 loc) · 2.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
ARG WRAP_IMAGE
ARG WRAP_COMMAND
ARG SSH_KEY_PATH
# Build image
FROM gcr.io/cloud-builders/go:1.21 AS builder
ARG VERSION="1.0-dev"
ADD . /app
WORKDIR /app
RUN go version
# Needs access to a google token and a ssh client
# RUN go test ./...
ENV GO111MODULE=on
RUN CGO_ENABLED=0 GOOS=linux go build -o auth-wrapper -ldflags "-X 'main.versionString=$VERSION'" ./cmd/authwrapper
RUN echo nobody:x:65534:65534:nobody:/: > password.minimal
#
# Auth-wrapper server image
#
FROM scratch AS main
ARG SSH_KEY_PATH
COPY --from=builder /app/auth-wrapper /opt/bin/auth-wrapper
COPY --from=builder /app/password.minimal /etc/password
USER nobody
ENTRYPOINT ["/opt/bin/auth-wrapper"]
#
# Authwrapped git with KMS keys
#
FROM gcr.io/cloud-builders/git AS git-kms
ARG SSH_KEY_PATH
COPY --from=builder /app/auth-wrapper /opt/bin/auth-wrapper
RUN ln -s /opt/bin/auth-wrapper /opt/bin/git
ENV GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
ENV PATH=/opt/bin:${PATH}
ENV SSH_KEY_PATH=${SSH_KEY_PATH}
ENTRYPOINT ["/opt/bin/git"]
#
# Authwrapped docker with KMS keys
#
FROM gcr.io/cloud-builders/docker AS docker-kms
ARG SSH_KEY_PATH
RUN apt-get update && apt-get install -y --no-install-recommends docker-buildx-plugin && apt-get clean -y && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/auth-wrapper /opt/bin/auth-wrapper
RUN ln -s /opt/bin/auth-wrapper /opt/bin/docker
ENV GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
RUN echo "Host *\n StrictHostKeyChecking no" > /etc/ssh/ssh_config.d/01-hostkey-disable.conf
ENV PATH=/opt/bin:${PATH}
ENV SSH_KEY_PATH=${SSH_KEY_PATH}
ENV DOCKER_BUILDKIT=1
ENTRYPOINT ["/opt/bin/docker"]
#
# Authwrapped git with local keys
#
FROM gcr.io/cloud-builders/git AS git-local
COPY --from=builder /app/auth-wrapper /opt/bin/auth-wrapper
RUN ln -s /opt/bin/auth-wrapper /opt/bin/git
COPY build.pem /
RUN chmod 600 /build.pem
ENV GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
ENV PATH=/opt/bin:${PATH}
ENV SSH_KEY_PATH=/build.pem
ENTRYPOINT ["/opt/bin/git"]