github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/apis/Dockerfile.build (about)

     1  FROM golang:1.22.0-alpine AS protoinstall
     2  ARG TARGETPLATFORM
     3  ARG TARGETARCH
     4  
     5  # Install protoc 3.6
     6  RUN apk add -u unzip ca-certificates curl
     7  RUN echo "${TARGETPLATFORM} / ${TARGETARCH}"
     8  RUN curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip -o /tmp/protoc-amd64.zip
     9  RUN curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-aarch_64.zip -o /tmp/protoc-arm64.zip
    10  RUN cd /usr/local/ && unzip /tmp/protoc-${TARGETARCH}.zip
    11  
    12  FROM golang:1.22.0
    13  ARG version=1.0.5
    14  ARG TOKEN
    15  
    16  ENV DART_CHANNEL=stable
    17  ENV DART_VERSION=2.15.1
    18  
    19  RUN set -eux; \
    20      apt-get update; \
    21      apt-get install -y --no-install-recommends \
    22          ca-certificates \
    23          curl \
    24          dnsutils \
    25          git \
    26          openssh-client \
    27          unzip \
    28      ; \
    29      rm -rf /var/lib/apt/lists/*
    30  
    31  # Create a minimal runtime environment for executing AOT-compiled Dart code
    32  # with the smallest possible image size.
    33  # usage: COPY --from=dart:xxx /runtime/ /
    34  # uses hard links here to save space
    35  RUN set -eux; \
    36      case "$(dpkg --print-architecture)" in \
    37          amd64) \
    38              TRIPLET="x86_64-linux-gnu" ; \
    39              FILES="/lib64/ld-linux-x86-64.so.2" ;; \
    40          armhf) \
    41              TRIPLET="arm-linux-gnueabihf" ; \
    42              FILES="/lib/ld-linux-armhf.so.3 \
    43                  /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3";; \
    44          arm64) \
    45              TRIPLET="aarch64-linux-gnu" ; \
    46              FILES="/lib/ld-linux-aarch64.so.1 \
    47                  /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1" ;; \
    48          *) \
    49              echo "Unsupported architecture" ; \
    50              exit 5;; \
    51      esac; \
    52      FILES="$FILES \
    53          /etc/nsswitch.conf \
    54          /etc/ssl/certs \
    55          /usr/share/ca-certificates \
    56          /lib/$TRIPLET/libc.so.6 \
    57          /lib/$TRIPLET/libdl.so.2 \
    58          /lib/$TRIPLET/libm.so.6 \
    59          /lib/$TRIPLET/libnss_dns.so.2 \
    60          /lib/$TRIPLET/libpthread.so.0 \
    61          /lib/$TRIPLET/libresolv.so.2 \
    62          /lib/$TRIPLET/librt.so.1"; \
    63      for f in $FILES; do \
    64          dir=$(dirname "$f"); \
    65          mkdir -p "/runtime$dir"; \
    66          cp --archive --link --dereference --no-target-directory "$f" "/runtime$f"; \
    67      done
    68  
    69  ENV DART_SDK /usr/lib/dart
    70  ENV PATH $DART_SDK/bin:$PATH
    71  
    72  WORKDIR /root
    73  RUN set -eux; \
    74      case "$(dpkg --print-architecture)" in \
    75          amd64) \
    76              SDK_ARCH="x64";; \
    77          armhf) \
    78              SDK_ARCH="arm";; \
    79          arm64) \
    80              SDK_ARCH="arm64";; \
    81      esac; \
    82      SDK="dartsdk-linux-${SDK_ARCH}-release.zip"; \
    83      BASEURL="https://storage.googleapis.com/dart-archive/channels"; \
    84      URL="$BASEURL/$DART_CHANNEL/release/$DART_VERSION/sdk/$SDK"; \
    85      echo "SDK: $URL" >> dart_setup.log ; \
    86      curl -fLO "$URL"; \
    87      unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK";
    88  
    89  RUN ls -al /usr/lib/dart
    90  RUN chmod -R a+rwx /usr/lib/dart
    91  
    92  RUN apt-get install -y git curl make sed
    93  COPY --from=protoinstall /usr/local/bin/protoc /usr/local/bin/
    94  
    95  # Install go tools
    96  RUN go mod init github.com/binkynet/build-image && \
    97      go install github.com/gogo/protobuf/protoc-gen-gogo@v1.3.2 && \
    98      go install github.com/gogo/protobuf/protoc-gen-gofast@v1.3.2 && \
    99      go install github.com/gogo/protobuf/protoc-gen-gogofaster@v1.3.2 && \
   100      go install golang.org/x/tools/cmd/goimports@v0.20.0 && \
   101      go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.19.1 && \
   102      #go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger && \
   103      go install github.com/golang/protobuf/protoc-gen-go@v1.5.4 && \
   104      go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v1.5.1
   105  
   106  # Install Dart protoc plugin
   107  RUN mkdir -p /dart/cache
   108  ENV PUB_CACHE=/dart/cache
   109  ENV PATH="${PATH}:/usr/lib/dart/bin:/dart/cache/bin"
   110  RUN pub global activate protoc_plugin
   111  RUN cp /dart/cache/bin/* /go/bin/
   112  
   113  RUN apt-get install -y bash
   114  RUN sh -c 'chsh -s /bin/bash'
   115  
   116  ENV GO111MODULE=off