Dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. FROM ubuntu:focal
  2. # apt packages
  3. ENV INSTALL_DEPS \
  4. bazel \
  5. ca-certificates \
  6. git \
  7. make \
  8. unzip \
  9. wget \
  10. maven \
  11. patch \
  12. python3 \
  13. python3-distutils \
  14. python3-setuptools
  15. RUN apt update && apt install -y -q --no-install-recommends curl openjdk-8-jdk gnupg
  16. RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
  17. && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
  18. && apt update \
  19. && apt install -y -q --no-install-recommends ${INSTALL_DEPS} \
  20. && apt clean \
  21. && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  22. # protoc
  23. ENV PROTOC_VER=3.15.5
  24. ENV PROTOC_REL=protoc-"${PROTOC_VER}"-linux-x86_64.zip
  25. RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v"${PROTOC_VER}/${PROTOC_REL}" \
  26. && unzip ${PROTOC_REL} -d protoc \
  27. && mv protoc /usr/local \
  28. && ln -s /usr/local/protoc/bin/protoc /usr/local/bin
  29. # go
  30. ENV GOROOT /usr/local/go
  31. ENV GOPATH /go
  32. ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
  33. ENV GORELEASE go1.14.7.linux-amd64.tar.gz
  34. RUN wget -q https://dl.google.com/go/$GORELEASE \
  35. && tar -C $(dirname $GOROOT) -xzf $GORELEASE \
  36. && rm $GORELEASE \
  37. && mkdir -p $GOPATH/{src,bin,pkg}
  38. # protoc-gen-go
  39. ENV PGG_PKG "google.golang.org/protobuf/cmd/protoc-gen-go"
  40. ENV PGG_PATH "${GOPATH}/src/${PGG_PKG}"
  41. ENV PGG_VER=v1.26.0
  42. RUN go get -d ${PGG_PKG} \
  43. && cd ${PGG_PATH} \
  44. && git checkout ${PGG_VER} \
  45. && go install \
  46. && cd - \
  47. && rm -rf ${PGG_PATH}
  48. # deps
  49. RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
  50. # buildozer
  51. RUN go get github.com/bazelbuild/buildtools/buildozer
  52. WORKDIR ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate
  53. COPY . .
  54. # python must be on PATH for the execution of py_binary bazel targets, but
  55. # the distribution we installed doesn't provide this alias
  56. RUN ln -s /usr/bin/python3.8 /usr/bin/python
  57. # python tooling for linting and uploading to PyPI
  58. RUN python3.8 -m easy_install pip \
  59. && python3.8 -m pip install -r requirements.txt
  60. RUN make build
  61. ENTRYPOINT ["make"]
  62. CMD ["build"]