-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·36 lines (31 loc) · 1.01 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·36 lines (31 loc) · 1.01 KB
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
#!/bin/bash
# Runs a command inside the quartier Docker container.
#
# Usage:
# ./run.sh node prospect/search.js "Berlin"
# ./run.sh bash tools/validate-html.sh projects/foo/redesign
# ./run.sh node prospect/serve.js
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
IMAGE_NAME="${QUARTIER_IMAGE:-quartier}"
# Build image if not available locally
if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
echo "Image not found, building locally..."
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
fi
TTY_FLAG=""
[ -t 0 ] && TTY_FLAG="-it"
# Headless jobs (spawned by the cockpit) set QUARTIER_NO_PORTS=1 so concurrent
# containers don't fight over the legacy UI ports.
PORT_FLAGS="-p 3456:3456 -p 3457:3457"
[ -n "$QUARTIER_NO_PORTS" ] && PORT_FLAGS=""
docker run --rm $TTY_FLAG \
--init \
--cap-add=SYS_ADMIN \
-v "$SCRIPT_DIR:/app" \
-v /dev/shm:/dev/shm \
-v /var/run/docker.sock:/var/run/docker.sock \
-e HOST_WORKSPACE="$SCRIPT_DIR" \
$PORT_FLAGS \
-w /app \
"$IMAGE_NAME" \
"$@"