forked from okteto/okteto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (49 loc) · 2.21 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
# syntax = docker/dockerfile:experimental
ARG KUBECTL_VERSION=1.29.4
ARG HELM_VERSION=3.14.4
ARG KUSTOMIZE_VERSION=5.4.1
FROM golang:1.22-bookworm as golang-builder
FROM golang-builder as kubectl-builder
ARG TARGETARCH
ARG KUBECTL_VERSION
RUN curl -sLf --retry 3 -o kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl && \
cp kubectl /usr/local/bin/kubectl && \
chmod +x /usr/local/bin/kubectl && \
/usr/local/bin/kubectl version --client=true
FROM golang-builder as helm-builder
ARG TARGETARCH
ARG HELM_VERSION
RUN curl -sLf --retry 3 -o helm.tar.gz https://get.helm.sh/helm-v${HELM_VERSION}-linux-${TARGETARCH}.tar.gz && \
mkdir -p helm && tar -C helm -xf helm.tar.gz && \
cp helm/linux-${TARGETARCH}/helm /usr/local/bin/helm && \
chmod +x /usr/local/bin/helm && \
/usr/local/bin/helm version
FROM golang-builder as kustomize-builder
ARG TARGETARCH
ARG KUSTOMIZE_VERSION
RUN curl -sLf --retry 3 -o kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz \
&& tar -xvzf kustomize.tar.gz -C /usr/local/bin \
&& chmod +x /usr/local/bin/kustomize \
&& /usr/local/bin/kustomize version
FROM golang-builder as builder
WORKDIR /okteto
ENV CGO_ENABLED=0
ARG VERSION_STRING=docker
COPY go.mod .
COPY go.sum .
RUN --mount=type=cache,target=/root/.cache go mod download
COPY . .
RUN --mount=type=cache,target=/root/.cache make build
RUN chmod +x /okteto/bin/okteto
# Test
RUN /okteto/bin/okteto version
COPY docker-credential-okteto /okteto/bin/docker-credential-okteto
FROM alpine:3
RUN apk add --no-cache bash ca-certificates
COPY --from=kubectl-builder /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=helm-builder /usr/local/bin/helm /usr/local/bin/helm
COPY --from=kustomize-builder /usr/local/bin/kustomize /usr/local/bin/kustomize
COPY --from=builder /okteto/bin/okteto /usr/local/bin/okteto
COPY --from=builder /okteto/bin/docker-credential-okteto /usr/local/bin/docker-credential-okteto
ENV OKTETO_DISABLE_SPINNER=true
ENV PS1="\[\e[36m\]\${OKTETO_NAMESPACE:-okteto}:\e[32m\]\${OKTETO_NAME:-dev} \[\e[m\]\W> "