forked from pex-tool/pex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtox.sh
executable file
·46 lines (39 loc) · 1.08 KB
/
dtox.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
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(git rev-parse --show-toplevel)"
BASE_INPUT=(
"${ROOT}/docker/base/Dockerfile"
)
base_hash=$(cat ${BASE_INPUT[@]} | git hash-object -t blob --stdin)
function base_id() {
docker images -q -f label=base_hash=${base_hash} pantsbuild/pex:base
}
if [[ -z "$(base_id)" ]]; then
docker build \
--tag pantsbuild/pex:base \
--label base_hash=${base_hash} \
"${ROOT}/docker/base"
fi
USER_INPUT=(
"${ROOT}/docker/user/Dockerfile"
"${ROOT}/docker/user/create_docker_image_user.sh"
)
user_hash=$(cat ${USER_INPUT[@]} | git hash-object -t blob --stdin)
if [[ -z "$(docker images -q -f label=user_hash=${user_hash} pantsbuild/pex:user)" ]]; then
docker build \
--build-arg BASE_ID=$(base_id) \
--build-arg USER=$(id -un) \
--build-arg UID=$(id -u) \
--build-arg GROUP=$(id -gn) \
--build-arg GID=$(id -g) \
--tag pantsbuild/pex:user \
--label user_hash=${user_hash} \
"${ROOT}/docker/user"
fi
exec docker run \
--interactive \
--tty \
--rm \
--volume $(pwd):/dev/pex \
pantsbuild/pex:user \
"$@"