-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
executable file
·34 lines (31 loc) · 793 Bytes
/
cli
File metadata and controls
executable file
·34 lines (31 loc) · 793 Bytes
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
#!/bin/bash
set -euf
self="${0}"
workdir="$(dirname "$(realpath "${self}")")"
cd "${workdir}"
DOCKER_IMAGE_NAME="${DOCKER_IMAGE_NAME:-fekle/cache-preload:latest}"
case "${1:-}" in
"fmt")
find . -not -path '*/\.*' -type f -name '*.py' -exec \
yapf -i --style .style.yapf -p -vv {} '+' || true
;;
"run")
exec python3 -O ./cache-preload.py ${@:2}
;;
"docker-build")
exec docker build -t "${DOCKER_IMAGE_NAME}" .
;;
"docker-push")
exec docker push "${DOCKER_IMAGE_NAME}"
;;
"docker-run")
exec docker run --rm -t --shm-size=2g \
--user "$(id -u):$(id -g)" \
-v "${workdir}:/workdir:rw" \
--workdir /workdir \
"${DOCKER_IMAGE_NAME}" ${@:2}
;;
*)
echo "usage: ${self} <fmt|docker-build|docker-run>"
;;
esac