File: dtox.sh

package info (click to toggle)
python-pex 1.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 2,840 kB
  • sloc: python: 9,757; sh: 1,394; makefile: 165
file content (46 lines) | stat: -rwxr-xr-x 1,101 bytes parent folder | download
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 \
  "$@"