forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_rebuild_google-vrp.sh
executable file
·51 lines (43 loc) · 2.08 KB
/
docker_rebuild_google-vrp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Script to rebuild Dockerfile-envoy-google-vrp locally (i.e. not in CI) for development purposes.
# This makes use of the latest envoy-dev base image on Docker Hub as the base and takes an
# optional local path for an Envoy binary. When a custom local Envoy binary is used, the script
# switches to using ${BASE_DOCKER_IMAGE} for the build, which should be configured to provide
# compatibility with your local build environment (specifically glibc).
#
# Usage:
#
# Basic rebuild of Docker image (tagged envoy-google-vrp:local):
#
# ./ci/docker_rebuild_google-vrp.sh
#
# Basic rebuild of Docker image (tagged envoy-google-vrp:local) with some local Envoy binary:
#
# bazel build //source/exe:envoy-static --config=libc++ -copt
# ./ci/docker_rebuild_google-vrp.sh bazel-bin/source/exe/envoy-static
set -e
# Don't use the local envoy-dev, but pull from Docker Hub instead, this avoids having to rebuild
# this local dep which is fairly stable.
BASE_DOCKER_IMAGE="envoyproxy/envoy-dev:latest"
BUILD_DIR="$(mktemp -d)"
declare -r BUILD_DIR
cp ci/Dockerfile-envoy "${BUILD_DIR}"
declare -r DOCKER_BUILD_FILE="${BUILD_DIR}"/Dockerfile-envoy
# If we have a local Envoy binary, use a variant of the build environment that supports it.
if [[ -n "$1" ]]; then
# This should match your local machine if you are building custom Envoy binaries outside of Docker.
# This provides compatibility of locally built Envoy and glibc in the Docker env.
BASE_DOCKER_IMAGE="ubuntu:20.04"
# Copy the binary to deal with symlinks in Bazel cache and Docker daemon confusion.
declare -r LOCAL_ENVOY="envoy-binary"
declare -r LOCAL_ENVOY_DIR="build_envoy"
mkdir -p "${LOCAL_ENVOY_DIR}"
cp -f "$1" "${LOCAL_ENVOY_DIR}/${LOCAL_ENVOY}"
sed -i -e "s@# ADD %local envoy bin%@ADD ${LOCAL_ENVOY_DIR}/${LOCAL_ENVOY}@" "${DOCKER_BUILD_FILE}"
fi
cat "${DOCKER_BUILD_FILE}"
DOCKER_BUILDKIT=1 docker build -t "envoy-google-vrp:local" --target envoy-google-vrp --build-arg "ENVOY_VRP_BASE_IMAGE=${BASE_DOCKER_IMAGE}" -f "${DOCKER_BUILD_FILE}" .
if [[ -n "$1" ]]; then
rm -rf "${LOCAL_ENVOY_DIR}"
fi
rm -r "${BUILD_DIR}"