Skip to content

Commit

Permalink
Upgrade build dependencies (#629)
Browse files Browse the repository at this point in the history
* Support arm64 and amd64 in Dockerfile

Signed-off-by: Elliot Jackson <[email protected]>

* upgrade go dependencies

Signed-off-by: Elliot Jackson <[email protected]>

* fix Dockerfile syntax

Signed-off-by: Elliot Jackson <[email protected]>

* update bazel dependencies

Signed-off-by: Elliot Jackson <[email protected]>

* add protobuf python dependency

Signed-off-by: Elliot Jackson <[email protected]>

* clean up cache after go install in dockerfile

Signed-off-by: Elliot Jackson <[email protected]>

* clean mod cache on each install

Signed-off-by: Elliot Jackson <[email protected]>

* upgrade go toolchain version to 1.19.1

Signed-off-by: Elliot Jackson <[email protected]>

Signed-off-by: Elliot Jackson <[email protected]>
  • Loading branch information
Elliot Jackson authored Sep 14, 2022
1 parent 61feee2 commit 4f96300
Show file tree
Hide file tree
Showing 17 changed files with 1,346 additions and 78 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//module",
"@org_golang_google_protobuf//types/pluginpb",
"@com_github_lyft_protoc_gen_star//:protoc-gen-star",
"@com_github_lyft_protoc_gen_star//lang/go",
"@org_golang_google_protobuf//types/pluginpb",
],
)
51 changes: 31 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
FROM ubuntu:focal


ENV DEBIAN_FRONTEND=noninteractive
# apt packages
ENV INSTALL_DEPS \
bazel \
ca-certificates \
git \
make \
zip \
unzip \
g++ \
wget \
maven \
patch \
python3 \
python3-distutils \
python3-setuptools

RUN apt update && apt install -y -q --no-install-recommends curl openjdk-8-jdk gnupg
python3-setuptools \
apt-transport-https \
curl \
openjdk-8-jdk \
gnupg

RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
&& curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
&& apt update \
RUN apt update \
&& apt install -y -q --no-install-recommends ${INSTALL_DEPS} \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
&& apt clean

# bazel
ENV BAZEL_VER=5.3.0
RUN wget -O bazel https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "x86_64") \
&& chmod +x bazel \
&& mv bazel usr/local/bin/bazel

# protoc
ENV PROTOC_VER=3.17.3
ENV PROTOC_REL=protoc-"${PROTOC_VER}"-linux-x86_64.zip
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v"${PROTOC_VER}/${PROTOC_REL}" \
ENV PROTOC_VER=21.5
RUN export PROTOC_REL=protoc-${PROTOC_VER}-linux-$([ $(uname -m) = "aarch64" ] && echo "aarch" || echo "x86")_64.zip \
&& wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/${PROTOC_REL} \
&& unzip ${PROTOC_REL} -d protoc \
&& mv protoc /usr/local \
&& ln -s /usr/local/protoc/bin/protoc /usr/local/bin
Expand All @@ -36,18 +42,23 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v"${PROTO
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
ENV GORELEASE go1.17.linux-amd64.tar.gz
RUN wget -q https://dl.google.com/go/$GORELEASE \
&& tar -C $(dirname $GOROOT) -xzf $GORELEASE \
&& rm $GORELEASE \
&& mkdir -p $GOPATH/{src,bin,pkg}
RUN export GORELEASE=go1.19.1.linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "amd64").tar.gz \
&& wget -q https://dl.google.com/go/$GORELEASE \
&& tar -C $(dirname $GOROOT) -xzf $GORELEASE \
&& rm $GORELEASE \
&& mkdir -p $GOPATH/{src,bin,pkg}

# protoc-gen-go
ENV PGG_VER=v1.27.1
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PGG_VER}
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PGG_VER} \
&& rm -rf $(go env GOCACHE) \
&& rm -rf $(go env GOMODCACHE)

# buildozer
RUN go get github.com/bazelbuild/buildtools/buildozer
ENV BDR_VER=5.1.0
RUN go install github.com/bazelbuild/buildtools/buildozer@${BDR_VER} \
&& rm -rf $(go env GOCACHE) \
&& rm -rf $(go env GOMODCACHE)

WORKDIR ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate
COPY . .
Expand Down
1 change: 0 additions & 1 deletion bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ string_flag(
build_setting_default = "",
visibility = ["//visibility:public"],
)

2 changes: 1 addition & 1 deletion bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _pgv_pip_dependencies():
def _pgv_go_dependencies():
go_rules_dependencies()
go_register_toolchains(
version = "1.15.6",
version = "1.19.1",
)
gazelle_dependencies()

Expand Down
17 changes: 9 additions & 8 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ def pgv_dependencies(maven_repos = _DEFAULT_REPOSITORIES):
if not native.existing_rule("io_bazel_rules_go"):
http_archive(
name = "io_bazel_rules_go",
sha256 = "6f111c57fd50baf5b8ee9d63024874dd2a014b069426156c55adbf6d3d22cb7b",
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.0/rules_go-v0.25.0.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.25.0/rules_go-v0.25.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
],
)

if not native.existing_rule("bazel_gazelle"):
http_archive(
name = "bazel_gazelle",
sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
],
)

Expand Down Expand Up @@ -129,8 +129,9 @@ def pgv_dependencies(maven_repos = _DEFAULT_REPOSITORIES):
if not native.existing_rule("rules_python"):
http_archive(
name = "rules_python",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
sha256 = "b593d13bb43c94ce94b483c2858e53a9b811f6f10e1e0eedc61073bd90e58d9c",
strip_prefix = "rules_python-0.12.0",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.12.0.tar.gz",
)

if not native.existing_rule("rules_proto"):
Expand Down
Loading

0 comments on commit 4f96300

Please sign in to comment.