-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dockerfile for new Bazel releases (#1290)
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ATTENTION: use the build.sh script to build this image. | ||
# ./build.sh <OCI_REPOSITORY> <BAZEL_VERSION> | ||
|
||
FROM ubuntu:16.04@sha256:0f71fa8d4d2d4292c3c617fda2b36f6dabe5c8b6e34c3dc5b0d17d4e704bd39c AS base_image | ||
|
||
RUN --mount=source=bazel/oci/install_packages.sh,target=/mnt/install_packages.sh,type=bind \ | ||
/mnt/install_packages.sh | ||
|
||
FROM base_image AS downloader | ||
|
||
ARG BAZEL_VERSION | ||
|
||
WORKDIR /var/bazel | ||
RUN --mount=source=bazel/oci/install_bazel.sh,target=/mnt/install_bazel.sh,type=bind \ | ||
/mnt/install_bazel.sh | ||
|
||
FROM base_image | ||
|
||
RUN useradd --system --create-home --home-dir=/home/ubuntu --shell=/bin/bash --gid=root --groups=sudo --uid=1000 ubuntu | ||
USER ubuntu | ||
WORKDIR /home/ubuntu | ||
COPY --from=downloader /var/bazel/bazel /usr/local/bin/bazel | ||
ENTRYPOINT ["/usr/local/bin/bazel"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
readonly OCI_REPOSITORY=$1 | ||
readonly BAZEL_VERSION=$2 | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
function print_usage() { | ||
>&2 echo "Usage: $0 <OCI_REPOSITORY> <BAZEL_VERSION>" | ||
} | ||
|
||
if [ -z "${OCI_REPOSITORY}" ]; then | ||
>&2 echo "ERROR: missing 'OCI_REPOSITORY' argument" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${BAZEL_VERSION}" ]; then | ||
>&2 echo "ERROR: missing 'BAZEL_VERSION' argument" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
GIT_ROOT=$(git rev-parse --show-toplevel) | ||
readonly GIT_ROOT | ||
|
||
if docker buildx version 2>&1 1>/dev/null; then | ||
buildx="buildx" | ||
fi | ||
|
||
docker ${buildx:+"${buildx}"} build \ | ||
--file "${GIT_ROOT}/bazel/oci/Dockerfile" \ | ||
--tag "${OCI_REPOSITORY}:${BAZEL_VERSION}" \ | ||
--build-arg BAZEL_VERSION="${BAZEL_VERSION}" \ | ||
"${GIT_ROOT}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
curl \ | ||
--fail \ | ||
--location \ | ||
--remote-name \ | ||
"https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64" | ||
|
||
curl \ | ||
--fail \ | ||
--location \ | ||
"https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64.sha256" \ | ||
| sha256sum --check | ||
|
||
mv "bazel-${BAZEL_VERSION}-linux-x86_64" bazel | ||
chmod +x bazel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
apt-get update | ||
|
||
export DEBIAN_FRONTEND="noninteractive" | ||
export TZ="Etc/UTC" | ||
|
||
apt-get install --yes \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
openjdk-8-jdk \ | ||
python3 \ | ||
python3-pip \ | ||
unzip \ | ||
zip | ||
|
||
ln -s "$(which python3)" /usr/bin/python |