<commit_before>#!/bin/bash
set -e
set -o pipefail
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

DOCKER_NO_CACHE=${DOCKER_NO_CACHE:-false}
[ "$DOCKER_NO_CACHE" = "true" ] && NO_CACHE="--no-cache" || NO_CACHE=""

bazel build //base:jessie //base:stretch

# when https://github.com/docker/docker/issues/9656 is fixed run docker builds in parallel

function build_image() {
  local dir="$1"
  local distro="$2"
  local app="$3"

  local random_tag="bazel_dep_$(cat /dev/urandom | head -c 10 | md5sum | awk '{print $1}')"

  docker build $NO_CACHE -t "$random_tag" -f "$dir/$app.Dockerfile" "$dir"
  local id=$(docker inspect --format="{{ .Id }}" "$random_tag")
  docker tag "$random_tag" "bazel/dependencies:$distro-$app"
  echo "$id"
}

readonly jessie_image=$(bazel run //base:jessie | grep "^Tagging" | awk '{print $4}')
docker tag "$jessie_image" bazel/base:jessie

for app in base ca-certificates grafana java nginx nodejs postgresql zulu; do
  # TODO do this in a single command
  build_image "$DIR/jessie" "jessie" "$app" | tee "$DIR/_built/jessie/$app.tmp"
  tail -n1 "$DIR/_built/jessie/$app.tmp" > "$DIR/_built/jessie/$app"
  rm -f "$DIR/_built/jessie/$app.tmp"
done

readonly stretch_image=$(bazel run //base:stretch | grep "^Tagging" | awk '{print $4}')
docker tag "$stretch_image" bazel/base:stretch

for app in base; do
  build_image "$DIR/stretch" "stretch" "$app" | tee "$DIR/_built/stretch/$app.tmp"
  tail -n1 "$DIR/_built/stretch/$app.tmp" > "$DIR/_built/stretch/$app"
  rm -f "$DIR/_built/stretch/$app.tmp"
done<commit_msg>Remove temp docker image after tag<commit_after>#!/bin/bash
set -e
set -o pipefail
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

DOCKER_NO_CACHE=${DOCKER_NO_CACHE:-false}
[ "$DOCKER_NO_CACHE" = "true" ] && NO_CACHE="--no-cache" || NO_CACHE=""

bazel build //base:jessie //base:stretch

# when https://github.com/docker/docker/issues/9656 is fixed run docker builds in parallel

function build_image() {
  local dir="$1"
  local distro="$2"
  local app="$3"

  local random_tag="bazel_dep_$(cat /dev/urandom | head -c 10 | md5sum | awk '{print $1}')"

  docker build $NO_CACHE -t "$random_tag" -f "$dir/$app.Dockerfile" "$dir"
  local id=$(docker inspect --format="{{ .Id }}" "$random_tag")
  docker tag "$random_tag" "bazel/dependencies:$distro-$app"
  docker rmi "$random_tag"
  echo "$id"
}

readonly jessie_image=$(bazel run //base:jessie | grep "^Tagging" | awk '{print $4}')
docker tag "$jessie_image" bazel/base:jessie

for app in base ca-certificates grafana java nginx nodejs postgresql zulu; do
  # TODO do this in a single command
  build_image "$DIR/jessie" "jessie" "$app" | tee "$DIR/_built/jessie/$app.tmp"
  tail -n1 "$DIR/_built/jessie/$app.tmp" > "$DIR/_built/jessie/$app"
  rm -f "$DIR/_built/jessie/$app.tmp"
done

readonly stretch_image=$(bazel run //base:stretch | grep "^Tagging" | awk '{print $4}')
docker tag "$stretch_image" bazel/base:stretch

for app in base; do
  build_image "$DIR/stretch" "stretch" "$app" | tee "$DIR/_built/stretch/$app.tmp"
  tail -n1 "$DIR/_built/stretch/$app.tmp" > "$DIR/_built/stretch/$app"
  rm -f "$DIR/_built/stretch/$app.tmp"
done
{'fraction_non_alphanumeric': 0.18144395186827106, 'fraction_numerical': 0.01013299556681444, 'mean_word_length': 4.532399299474606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4087224', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1187, 'n_words': 297}