github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/build-aux/docker/images/Dockerfile.client (about)

     1  # syntax = docker/dockerfile:1.3
     2  
     3  # Copyright 2020-2022 Datawire. All rights reserved.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  FROM --platform=$BUILDPLATFORM golang:alpine as telepresence-build
    18  
    19  RUN apk add --no-cache gcc musl-dev fuse-dev libcap binutils-gold
    20  
    21  WORKDIR telepresence
    22  COPY go.mod .
    23  COPY go.sum .
    24  COPY cmd/telepresence/ cmd/telepresence/
    25  COPY pkg/ pkg/
    26  COPY rpc/ rpc/
    27  COPY charts/ charts/
    28  COPY build-output/version.txt .
    29  
    30  ARG TARGETOS
    31  ARG TARGETARCH
    32  
    33  RUN \
    34      --mount=type=cache,target=/root/.cache/go-build \
    35      --mount=type=cache,target=/go/pkg/mod \
    36      GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /usr/local/bin/ -trimpath -tags docker -ldflags=-X=$(go list ./pkg/version).Version=$(cat version.txt) ./cmd/telepresence/...
    37  
    38  # setcap is necessary because the process will listen to privileged ports
    39  RUN setcap 'cap_net_bind_service+ep' /usr/local/bin/telepresence
    40  
    41  # The telepresence target is the one that gets published. It aims to be a small as possible.
    42  FROM alpine as telepresence
    43  
    44  RUN apk add --no-cache ca-certificates iptables iptables-legacy bash
    45  RUN rm /sbin/iptables && ln -s /sbin/iptables-legacy /sbin/iptables
    46  RUN rm /sbin/ip6tables && ln -s /sbin/ip6tables-legacy /sbin/ip6tables
    47  
    48  # the telepresence binary
    49  COPY --from=telepresence-build /usr/local/bin/telepresence /usr/local/bin
    50  
    51  ENTRYPOINT ["telepresence"]
    52  CMD []