-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile-cnsenter
21 lines (19 loc) · 956 Bytes
/
Dockerfile-cnsenter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Build cnsenter
FROM golang:1.16 as builder
ARG VERSION
WORKDIR /workspace
COPY . .
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags="-X 'github.com/ssup2/kpexec/pkg/cmd/cnsenter.version=${VERSION}'" -o cnsenter cmd/cnsenter/main.go
# Download crictl
FROM alpine:3.13.1 as downloader
ARG TARGETPLATFORM
ENV CRICTL_VERSION v1.24.1
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCHITECTURE=arm; else ARCHITECTURE=amd64; fi \
&& wget https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCHITECTURE}.tar.gz
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCHITECTURE=arm; else ARCHITECTURE=amd64; fi \
&& tar zxvf crictl-${CRICTL_VERSION}-linux-${ARCHITECTURE}.tar.gz -C /usr/local/bin
# Build image
FROM alpine:3.13.1
COPY --from=builder /workspace/cnsenter /usr/local/bin/cnsenter
COPY --from=downloader /usr/local/bin/crictl /usr/local/bin/crictl
CMD ["cnsenter"]