-
-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathcontainer-start-dev.sh
More file actions
69 lines (55 loc) · 1.9 KB
/
container-start-dev.sh
File metadata and controls
69 lines (55 loc) · 1.9 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -e
CACHE_DIR="/cache"
APP="shadow-cljs"
# Helper function to create symlinks from the cache volume
setup_symlink() {
local target_path=$1
local cache_path=$2
# Ensure the cache directory exists
mkdir -p "$cache_path"
mkdir -p "$target_path"
# If the target already exists and is exactly the symlink we want, do nothing
if [ -L "$target_path" ] && [ "$(readlink "$target_path")" = "$cache_path" ]; then
return
fi
# If a real directory is in the way from the host, remove it to enforce isolation
if [ -d "$target_path" ] && [ ! -L "$target_path" ]; then
rm -rf "$target_path"
elif [ -e "$target_path" ]; then
rm -f "$target_path"
fi
# Create symlink pointing the workspace/host target to the cache volume
ln -s "$cache_path" "$target_path"
}
echo "Setting up isolated cache symlinks..."
# Initialize workspace cache directories
setup_symlink "/code/shadow-cljs/node_modules" "$CACHE_DIR/$APP/node_modules"
# Initialize system-level caches
setup_symlink "$HOME/.npm" "$CACHE_DIR/npm"
setup_symlink "$HOME/.m2" "$CACHE_DIR/m2"
setup_symlink "$HOME/.lein" "$CACHE_DIR/lein"
# Dependency change detection (npm)
NPM_HASH_FILE="$CACHE_DIR/$APP/npm_deps_hash.md5"
# Hash both package.json and lockfile if it exists to detect any dependency changes
if [ -f package-lock.json ]; then
CURRENT_NPM_HASH=$(md5sum package.json package-lock.json | md5sum | awk '{print $1}')
else
CURRENT_NPM_HASH=$(md5sum package.json | md5sum | awk '{print $1}')
fi
if [ ! -f "$NPM_HASH_FILE" ] || [ "$(cat "$NPM_HASH_FILE")" != "$CURRENT_NPM_HASH" ]; then
echo "NPM dependencies changed (or first run). Installing..."
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
echo "$CURRENT_NPM_HASH" > "$NPM_HASH_FILE"
else
echo "✔ NPM dependencies are up to date."
fi
echo "Running javac ..."
lein javac
# run dev server
echo "Starting ..."
exec clj -M:dev:start "$@"