...

Text file src/github.com/linkerd/linkerd2/web/Dockerfile

Documentation: github.com/linkerd/linkerd2/web

     1ARG BUILDPLATFORM=linux/amd64
     2
     3# Precompile key slow-to-build dependencies
     4FROM --platform=$BUILDPLATFORM golang:1.22-alpine as go-deps
     5WORKDIR /linkerd-build
     6COPY go.mod go.sum ./
     7COPY bin/install-deps bin/
     8RUN go mod download
     9ARG TARGETARCH
    10RUN ./bin/install-deps $TARGETARCH
    11
    12## bundle web assets
    13FROM --platform=$BUILDPLATFORM node:20-bookworm as webpack-bundle
    14RUN bin/scurl --retry=2 https://yarnpkg.com/install.sh | bash -s -- --version 1.22.10 --network-concurrency 1
    15
    16ENV PATH /root/.yarn/bin:$PATH
    17ENV ROOT /linkerd-build
    18WORKDIR $ROOT
    19
    20# copy build script
    21COPY bin/web ./bin/web
    22
    23# install yarn dependencies
    24COPY web/app/package.json web/app/yarn.lock ./web/app/
    25RUN ./bin/web setup install --frozen-lockfile
    26
    27# build frontend assets
    28# set the env to production *after* yarn has done an install, to make sure all
    29# libraries required for building are included.
    30ENV NODE_ENV production
    31COPY web/app ./web/app
    32RUN ./bin/web build
    33
    34## compile go server
    35FROM go-deps as golang
    36WORKDIR /linkerd-build
    37RUN mkdir -p web
    38COPY web/main.go web
    39COPY web/srv web/srv
    40COPY controller controller
    41COPY viz/metrics-api viz/metrics-api
    42COPY viz/pkg viz/pkg
    43COPY viz/tap/gen/tap viz/tap/gen/tap
    44COPY viz/tap/pkg viz/tap/pkg
    45COPY pkg pkg
    46ARG TARGETARCH
    47RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -mod=readonly -o web/web -ldflags "-s -w" ./web
    48
    49## package it all up
    50FROM scratch
    51WORKDIR /linkerd
    52
    53COPY LICENSE .
    54COPY --from=golang /linkerd-build/web/web .
    55COPY --from=webpack-bundle /linkerd-build/web/app/dist app/dist
    56COPY web/templates templates
    57COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
    58
    59ARG LINKERD_VERSION
    60ENV LINKERD_CONTAINER_VERSION_OVERRIDE=${LINKERD_VERSION}
    61
    62ENTRYPOINT ["./web"]

View as plain text