-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch build-from-scratch in https://github.com/ochafik/bazel.git now compiles deps as needed
- Loading branch information
Showing
4 changed files
with
65 additions
and
82 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
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
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 |
---|---|---|
@@ -1,30 +1,51 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
if [[ ! -d dist-amd64 ]]; then | ||
cat Dockerfile | sed 's/resin\/rpi-raspbian:stretch/debian:stretch/' > Dockerfile.debian | ||
docker build -t debian-bazel-build -f Dockerfile.debian . | ||
|
||
mkdir dist-amd64 | ||
id=$(docker create debian-bazel-build) | ||
docker cp $id:bazel/output/bazel dist-amd64 | ||
docker rm -v $id | ||
echo " | ||
FROM debian-bazel-build | ||
COPY ./dist-amd64/bazel /usr/bin | ||
" > Dockerfile.debian-slim | ||
docker build -t debian-bazel -f Dockerfile.debian-slim . | ||
fi | ||
|
||
if [[ ! -d dist-armhf ]]; then | ||
docker build -t rpi-raspbian-bazel-build . | ||
mkdir dist-armhf | ||
id=$(docker create rpi-raspbian-bazel-build) | ||
docker cp $id:bazel/output/bazel dist-armhf | ||
docker rm -v $id | ||
echo " | ||
FROM rpi-raspbian-bazel-build | ||
COPY ./dist-armhf/bazel /usr/bin | ||
" > Dockerfile.raspbian-slim | ||
docker build -t rpi-raspbian-bazel -f Dockerfile.raspbian-slim . | ||
fi | ||
readonly BAZEL_OUTPUT=/bazel/output/bazel | ||
|
||
function build_bazel_docker() { | ||
local build_image_base="$1" | ||
local build_image_name="$2" | ||
local normal_image_base="$3" | ||
local normal_image_name="$4" | ||
local slim_image_base="$5" | ||
local slim_image_name="$6" | ||
local dist_dir="$7" | ||
|
||
if [[ ! -d "$dist_dir" ]]; then | ||
cat Dockerfile | \ | ||
sed "s/resin\/rpi-raspbian:stretch/$(echo "$build_image_base" | sed 's/\//\\\//g')/" | | ||
docker build -t "$build_image_name" - | ||
|
||
mkdir -p "$dist_dir" | ||
id=$(docker create "$build_image_name") | ||
docker cp "$id:$BAZEL_OUTPUT" "$dist_dir" | ||
docker rm -v $id | ||
|
||
echo " | ||
FROM $normal_image_base | ||
COPY ./$dist_dir/bazel /usr/bin | ||
" | \ | ||
docker build -t "$normal_image_name" - | ||
|
||
echo " | ||
FROM $slim_image_base | ||
COPY ./$dist_dir/bazel /usr/bin | ||
" | \ | ||
docker build -t "$slim_image_name" - | ||
fi | ||
} | ||
|
||
# Use native Debian as a canary of sorts: this will fail way faster than the | ||
# QEMU rasbian build. | ||
build_bazel_docker \ | ||
debian:stretch debian-bazel-build \ | ||
debian:stretch debian-bazel \ | ||
debian:stretch-slim debian-bazel-slim \ | ||
dist-amd64 | ||
|
||
build_bazel_docker \ | ||
resin/rpi-raspbian:stretch rpi-raspbian-bazel-build \ | ||
resin/rpi-raspbian:stretch rpi-raspbian-bazel \ | ||
resin/rpi-raspbian:stretch-slim rpi-raspbian-bazel-slim \ | ||
dist-armhf |
This file was deleted.
Oops, something went wrong.