This repository was archived by the owner on Feb 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
77 lines (64 loc) · 2.29 KB
/
docker-entrypoint.sh
File metadata and controls
77 lines (64 loc) · 2.29 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
70
71
72
73
74
75
76
77
#!/bin/sh
set -e
if [ "$(id -u)" = "0" ]; then
echo "Running as root, fixing volume permissions..."
if [ -d /usr/src/app/logs ]; then
echo "Fixing permissions for /usr/src/app/logs"
if ! chown -R node:node /usr/src/app/logs; then
echo "Warning: Could not change ownership of /usr/src/app/logs" >&2
fi
fi
if [ -d /var/lib/postgresql/data ]; then
echo "Fixing permissions for /var/lib/postgresql/data"
if ! chown -R node:node /var/lib/postgresql/data; then
echo "Warning: Could not change ownership of /var/lib/postgresql/data" >&2
fi
fi
if [ -d /data/redis ]; then
echo "Fixing permissions for /data/redis"
if ! chown -R node:node /data/redis; then
echo "Warning: Could not change ownership of /data/redis" >&2
fi
fi
echo "Switching to node user with su-exec..."
if command -v su-exec >/dev/null 2>&1; then
exec su-exec node "$0" "$@"
else
echo "ERROR: su-exec not found! Falling back to su"
# shellcheck disable=SC2016
exec su node -s /bin/sh -c 'exec "$0" "$@"' -- "$0" "$@"
fi
fi
# 이하 node 유저로 실행
echo "Running as $(whoami) (UID: $(id -u))"
# PJSe.json 자동 다운로드
PJSe_FILE="/usr/src/app/exchanges/PJSe.json"
DEFAULT_PJSe_URL="https://raw.githubusercontent.com/0ghost0-dev/PJS2/refs/heads/next/exchanges/PJSe.json"
if [ ! -f "$PJSe_FILE" ]; then
echo "PJSe.json not found. Downloading from GitHub..."
mkdir -p /usr/src/app/exchanges
PJSe_URL="${PJSe_CONFIG_URL:-$DEFAULT_PJSe_URL}"
if command -v wget >/dev/null 2>&1; then
wget -q "$PJSe_URL" -O "$PJSe_FILE" || {
echo "Error: Failed to download PJSe.json from $PJSe_URL"
exit 1
}
elif command -v curl >/dev/null 2>&1; then
curl -fsSL "$PJSe_URL" -o "$PJSe_FILE" || {
echo "Error: Failed to download PJSe.json from $PJSe_URL"
exit 1
}
else
echo "Error: Neither wget nor curl available"
exit 1
fi
echo "Successfully downloaded PJSe.json from $PJSe_URL"
else
echo "PJSe.json already exists at $PJSe_FILE"
fi
echo "Waiting for Postgres at ${POSTGRESQL_HOST:-postgres}:${POSTGRESQL_PORT:-5432}..."
until pg_isready -h "${POSTGRESQL_HOST:-postgres}" -p "${POSTGRESQL_PORT:-5432}" -U "${POSTGRESQL_USER:-postgres}" >/dev/null 2>&1; do
sleep 1
done
echo "Postgres is available. Starting app..."
exec "$@"