# syntax = docker/dockerfile:1.3 # Copyright 2020-2022 Datawire. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. FROM --platform=$BUILDPLATFORM golang:alpine as telepresence-build RUN apk add --no-cache gcc musl-dev fuse-dev libcap binutils-gold WORKDIR telepresence COPY go.mod . COPY go.sum . COPY cmd/cobraparser/ cmd/cobraparser/ COPY cmd/telepresence/ cmd/telepresence/ COPY pkg/ pkg/ COPY rpc/ rpc/ COPY charts/ charts/ COPY build-output/version.txt . COPY build-output/helm-version.txt . ARG TARGETOS ARG TARGETARCH RUN \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /usr/local/bin/ -trimpath -tags docker -ldflags="-s -w -X=$(go list ./pkg/version).Version=$(cat version.txt) -X=$(go list ./pkg/version).HelmVersion=$(cat helm-version.txt)" ./cmd/telepresence/... # setcap is necessary because the process will listen to privileged ports RUN setcap 'cap_net_bind_service+ep' /usr/local/bin/telepresence # The telepresence target is the one that gets published. It aims to be a small as possible. FROM alpine as telepresence RUN apk add --no-cache ca-certificates iptables # the telepresence binary COPY --from=telepresence-build /usr/local/bin/telepresence /usr/local/bin ENTRYPOINT ["telepresence"] CMD []