-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
44 lines (39 loc) · 1.37 KB
/
docker-entrypoint.sh
File metadata and controls
44 lines (39 loc) · 1.37 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
#!/bin/bash
set -e
# Platformdirs default config path (mirrors a regular Linux install):
# ~/.config/pixlstash/server-config.json
# Override by setting PIXLSTASH_CONFIG in the environment.
CONFIG_PATH="${PIXLSTASH_CONFIG:-${HOME}/.config/pixlstash/server-config.json}"
HOST="${PIXLSTASH_HOST:-0.0.0.0}"
PORT="${PIXLSTASH_PORT:-9537}"
export PIXLSTASH_IN_DOCKER=1
mkdir -p "$(dirname "$CONFIG_PATH")"
# Write a default config on first run with Docker-appropriate settings
# (host 0.0.0.0 so the server is reachable from outside the container).
# If the config already exists it is left untouched so user edits survive restarts.
if [ ! -f "$CONFIG_PATH" ]; then
echo "Creating default server config at $CONFIG_PATH"
# Default image_root mirrors what Server._init_server_config uses:
# os.path.join(config_dir, "images")
DEFAULT_IMAGE_ROOT="$(dirname "$CONFIG_PATH")/images"
IMAGE_ROOT="${PIXLSTASH_IMAGE_ROOT:-$DEFAULT_IMAGE_ROOT}"
mkdir -p "$IMAGE_ROOT"
cat > "$CONFIG_PATH" <<EOF
{
"host": "$HOST",
"port": $PORT,
"log_level": "info",
"log_file": null,
"require_ssl": false,
"cookie_samesite": "Lax",
"cookie_secure": false,
"image_root": "$IMAGE_ROOT",
"default_device": "auto",
"min_free_disk_gb": 1.0,
"min_free_vram_mb": 1024.0,
"cors_origins": [],
"watch_folders": []
}
EOF
fi
exec python -m pixlstash.app --server-config "$CONFIG_PATH" "$@"