f2d90b38 commited on
Commit
a38895d
·
verified ·
1 Parent(s): 6e33041

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +29 -0
  2. nginx.conf.template +27 -0
  3. public/index.html +67 -0
  4. start.sh +104 -0
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM eceasy/cli-proxy-api:latest
2
+
3
+ # Install nginx + envsubst for templating.
4
+ RUN if command -v apt-get >/dev/null 2>&1; then \
5
+ apt-get update \
6
+ && apt-get install -y --no-install-recommends nginx gettext-base ca-certificates \
7
+ && rm -rf /var/lib/apt/lists/*; \
8
+ elif command -v apk >/dev/null 2>&1; then \
9
+ apk add --no-cache nginx gettext ca-certificates; \
10
+ else \
11
+ echo "No supported package manager found for nginx install." \
12
+ && exit 1; \
13
+ fi
14
+
15
+ ENV PORT=7860
16
+ ENV PROXY_PATH=/api
17
+ ENV CLI_PROXY_HOST=127.0.0.1
18
+ ENV CLI_PROXY_PORT=8317
19
+ ENV CONFIG_PATH=/data/config.yaml
20
+ ENV AUTH_DIR=/data/auth
21
+
22
+ COPY nginx.conf.template /etc/nginx/templates/default.conf.template
23
+ COPY public /usr/share/nginx/html
24
+ COPY start.sh /start.sh
25
+ RUN chmod +x /start.sh
26
+
27
+ EXPOSE 7860
28
+
29
+ ENTRYPOINT ["/start.sh"]
nginx.conf.template ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen ${PORT};
3
+ server_name _;
4
+
5
+ root /usr/share/nginx/html;
6
+ index index.html;
7
+
8
+ location = / {
9
+ try_files /index.html =404;
10
+ }
11
+
12
+ location = ${PROXY_PATH} {
13
+ return 301 ${PROXY_PATH}/;
14
+ }
15
+
16
+ location ${PROXY_PATH}/ {
17
+ proxy_pass http://${CLI_PROXY_HOST}:${CLI_PROXY_PORT}/;
18
+ proxy_http_version 1.1;
19
+ proxy_set_header Host $host;
20
+ proxy_set_header X-Real-IP $remote_addr;
21
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
+ proxy_set_header X-Forwarded-Proto $scheme;
23
+ proxy_set_header Upgrade $http_upgrade;
24
+ proxy_set_header Connection "upgrade";
25
+ proxy_read_timeout 300;
26
+ }
27
+ }
public/index.html ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Service Status</title>
7
+ <style>
8
+ :root {
9
+ --bg: #f2efe8;
10
+ --ink: #1d1b16;
11
+ --accent: #a14a3b;
12
+ --muted: #6f6b62;
13
+ }
14
+ * {
15
+ box-sizing: border-box;
16
+ }
17
+ body {
18
+ margin: 0;
19
+ font-family: "Georgia", "Times New Roman", serif;
20
+ color: var(--ink);
21
+ min-height: 100vh;
22
+ display: grid;
23
+ place-items: center;
24
+ background:
25
+ radial-gradient(900px 500px at 10% 10%, #f8f5ee 0%, transparent 60%),
26
+ radial-gradient(700px 400px at 90% 90%, #eadcd0 0%, transparent 55%),
27
+ var(--bg);
28
+ }
29
+ .card {
30
+ width: min(720px, 92vw);
31
+ background: #fff8f0;
32
+ border: 2px solid #d9c8b6;
33
+ padding: 36px 42px;
34
+ box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
35
+ }
36
+ h1 {
37
+ margin: 0 0 12px 0;
38
+ font-size: clamp(28px, 4vw, 40px);
39
+ letter-spacing: 0.5px;
40
+ }
41
+ p {
42
+ margin: 6px 0;
43
+ font-size: 16px;
44
+ line-height: 1.6;
45
+ color: var(--muted);
46
+ }
47
+ .tag {
48
+ display: inline-block;
49
+ margin-top: 14px;
50
+ padding: 6px 12px;
51
+ border: 1px solid var(--accent);
52
+ color: var(--accent);
53
+ font-size: 12px;
54
+ letter-spacing: 1px;
55
+ text-transform: uppercase;
56
+ }
57
+ </style>
58
+ </head>
59
+ <body>
60
+ <main class="card">
61
+ <h1>Service Monitor</h1>
62
+ <p>All systems report nominal status. External access is limited.</p>
63
+ <p>If you expected an API endpoint here, please verify the integration path.</p>
64
+ <span class="tag">STATUS: GREEN</span>
65
+ </main>
66
+ </body>
67
+ </html>
start.sh ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ -z "${PROXY_PATH:-}" ]]; then
5
+ PROXY_PATH="/api"
6
+ fi
7
+ if [[ "${PROXY_PATH}" != /* ]]; then
8
+ PROXY_PATH="/${PROXY_PATH}"
9
+ fi
10
+ if [[ "${PROXY_PATH}" == "/" ]]; then
11
+ echo "PROXY_PATH cannot be '/' because '/' is reserved for the cover page."
12
+ exit 1
13
+ fi
14
+
15
+ CONFIG_PATH="${CONFIG_PATH:-/data/config.yaml}"
16
+ AUTH_DIR="${AUTH_DIR:-/data/auth}"
17
+
18
+ mkdir -p "$(dirname "${CONFIG_PATH}")" "${AUTH_DIR}"
19
+ if [[ -f "${CONFIG_PATH}" ]]; then
20
+ ln -sf "${CONFIG_PATH}" /CLIProxyAPI/config.yaml
21
+ fi
22
+ if [[ -e /root/.cli-proxy-api && ! -L /root/.cli-proxy-api ]]; then
23
+ rm -rf /root/.cli-proxy-api
24
+ fi
25
+ ln -sfn "${AUTH_DIR}" /root/.cli-proxy-api
26
+
27
+ NGINX_CONF_DIR="/etc/nginx/conf.d"
28
+ if [[ -d "/etc/nginx/http.d" ]]; then
29
+ NGINX_CONF_DIR="/etc/nginx/http.d"
30
+ fi
31
+
32
+ export PROXY_PATH CLI_PROXY_HOST CLI_PROXY_PORT PORT
33
+ envsubst '${PORT} ${PROXY_PATH} ${CLI_PROXY_HOST} ${CLI_PROXY_PORT}' \
34
+ < /etc/nginx/templates/default.conf.template \
35
+ > "${NGINX_CONF_DIR}/default.conf"
36
+
37
+ detect_cmd() {
38
+ if [[ -n "${CLI_PROXY_CMD:-}" ]]; then
39
+ echo "${CLI_PROXY_CMD}"
40
+ return 0
41
+ fi
42
+ if [[ -x "/docker-entrypoint.sh" ]]; then
43
+ echo "/docker-entrypoint.sh"
44
+ return 0
45
+ fi
46
+ if [[ -x "/entrypoint.sh" ]]; then
47
+ echo "/entrypoint.sh"
48
+ return 0
49
+ fi
50
+ if [[ -x "/start.sh" && "/start.sh" != "$0" ]]; then
51
+ echo "/start.sh"
52
+ return 0
53
+ fi
54
+ if [[ -x "/CLIProxyAPI/cli-proxy-api" ]]; then
55
+ echo "/CLIProxyAPI/cli-proxy-api"
56
+ return 0
57
+ fi
58
+ if [[ -x "/CLIProxyAPI/start.sh" ]]; then
59
+ echo "/CLIProxyAPI/start.sh"
60
+ return 0
61
+ fi
62
+ if [[ -x "/CLIProxyAPI/run.sh" ]]; then
63
+ echo "/CLIProxyAPI/run.sh"
64
+ return 0
65
+ fi
66
+ if [[ -x "/CLIProxyAPI/CLIProxyAPI" ]]; then
67
+ echo "/CLIProxyAPI/CLIProxyAPI"
68
+ return 0
69
+ fi
70
+ if [[ -f "/CLIProxyAPI/main.py" ]]; then
71
+ echo "python /CLIProxyAPI/main.py"
72
+ return 0
73
+ fi
74
+ if [[ -f "/CLIProxyAPI/app.py" ]]; then
75
+ echo "python /CLIProxyAPI/app.py"
76
+ return 0
77
+ fi
78
+ if [[ -f "/CLIProxyAPI/server.py" ]]; then
79
+ echo "python /CLIProxyAPI/server.py"
80
+ return 0
81
+ fi
82
+ if [[ -f "/CLIProxyAPI/index.js" ]]; then
83
+ echo "node /CLIProxyAPI/index.js"
84
+ return 0
85
+ fi
86
+ if [[ -f "/CLIProxyAPI/package.json" ]]; then
87
+ echo "npm start --prefix /CLIProxyAPI"
88
+ return 0
89
+ fi
90
+ return 1
91
+ }
92
+
93
+ CLI_CMD="$(detect_cmd || true)"
94
+ if [[ -z "${CLI_CMD}" ]]; then
95
+ echo "Cannot detect how to start CLIProxyAPI."
96
+ echo "Set CLI_PROXY_CMD in Space Variables to the correct launch command."
97
+ exit 1
98
+ fi
99
+
100
+ echo "Starting CLIProxyAPI: ${CLI_CMD}"
101
+ sh -c "${CLI_CMD}" &
102
+
103
+ echo "Starting nginx on port ${PORT}, proxy path ${PROXY_PATH}"
104
+ exec nginx -g 'daemon off;'