# syntax=docker/dockerfile:1

FROM docker.io/golang:1.24.1

# Image layers go from less likely to most likely to change.
RUN apt-get update && \
  apt-get install -y --no-install-recommends \
    npm \
    unzip \
    && \
  rm -rf /var/lib/apt/lists/*

# protoc-gen-gogofast
# Keep in sync with api/proto/buf.yaml (and buf.lock)
# eg, "v1.3.2"
ARG GOGO_PROTO_TAG
RUN go install "github.com/gogo/protobuf/protoc-gen-gogofast@$GOGO_PROTO_TAG"

# protoc-gen-js and protoc-gen-ts
# eg, "1.12.4"
ARG NODE_GRPC_TOOLS_VERSION
# eg, "5.0.1"
ARG NODE_PROTOC_TS_VERSION
RUN npm install --global "grpc-tools@$NODE_GRPC_TOOLS_VERSION" "grpc_tools_node_protoc_ts@$NODE_PROTOC_TS_VERSION"

# buf
# eg, "v1.26.1"
ARG BUF_VERSION
RUN VERSION="$BUF_VERSION"; \
    go install "github.com/bufbuild/buf/cmd/buf@$VERSION"

# Pre-install go-runned binaries.
# This is meant to be the only step that changes depending on the Teleport
# branch.
COPY go.mod go.sum /teleport-module/
RUN cd /teleport-module; \
  go install connectrpc.com/connect/cmd/protoc-gen-connect-go && \
  go install google.golang.org/grpc/cmd/protoc-gen-go-grpc && \
  go install google.golang.org/protobuf/cmd/protoc-gen-go
