Spaces:
Running
Running
Hermes Agent commited on
Commit ·
8e431aa
1
Parent(s): 1a1dd51
feat: Add Nginx reverse proxy to expose OmniRoute Dashboard at /omniroute/ and OpenCode at /
Browse files- Dockerfile +4 -3
- entrypoint.sh +6 -3
- nginx.conf +37 -0
Dockerfile
CHANGED
|
@@ -9,12 +9,13 @@ ENV XDG_STATE_HOME=/data/state
|
|
| 9 |
|
| 10 |
ARG OPENCODE_VERSION=1.18.3
|
| 11 |
|
| 12 |
-
# Install dependencies (including git, python3, curl, ca-certificates)
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
curl \
|
| 15 |
ca-certificates \
|
| 16 |
git \
|
| 17 |
python3 \
|
|
|
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
# Install Node.js 20 LTS (required for OmniRoute modern JS/Regex features)
|
|
@@ -24,8 +25,6 @@ RUN curl -fsSL https://nodejs.org/dist/v20.18.0/node-v20.18.0-linux-x64.tar.gz \
|
|
| 24 |
# Install OmniRoute globally
|
| 25 |
RUN npm install -g omniroute
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
# Download opencode binary
|
| 30 |
RUN curl -fsSL "https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_VERSION}/opencode-linux-x64.tar.gz" \
|
| 31 |
| tar -xz -C /usr/local/bin opencode
|
|
@@ -35,8 +34,10 @@ RUN mkdir -p /projects/default
|
|
| 35 |
|
| 36 |
COPY cleaner.py /cleaner.py
|
| 37 |
COPY entrypoint.sh /entrypoint.sh
|
|
|
|
| 38 |
RUN chmod +x /entrypoint.sh
|
| 39 |
|
|
|
|
| 40 |
WORKDIR /projects/default
|
| 41 |
|
| 42 |
EXPOSE 4096
|
|
|
|
| 9 |
|
| 10 |
ARG OPENCODE_VERSION=1.18.3
|
| 11 |
|
| 12 |
+
# Install dependencies (including git, python3, curl, ca-certificates, nginx)
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
curl \
|
| 15 |
ca-certificates \
|
| 16 |
git \
|
| 17 |
python3 \
|
| 18 |
+
nginx \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
# Install Node.js 20 LTS (required for OmniRoute modern JS/Regex features)
|
|
|
|
| 25 |
# Install OmniRoute globally
|
| 26 |
RUN npm install -g omniroute
|
| 27 |
|
|
|
|
|
|
|
| 28 |
# Download opencode binary
|
| 29 |
RUN curl -fsSL "https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_VERSION}/opencode-linux-x64.tar.gz" \
|
| 30 |
| tar -xz -C /usr/local/bin opencode
|
|
|
|
| 34 |
|
| 35 |
COPY cleaner.py /cleaner.py
|
| 36 |
COPY entrypoint.sh /entrypoint.sh
|
| 37 |
+
COPY nginx.conf /nginx.conf
|
| 38 |
RUN chmod +x /entrypoint.sh
|
| 39 |
|
| 40 |
+
|
| 41 |
WORKDIR /projects/default
|
| 42 |
|
| 43 |
EXPOSE 4096
|
entrypoint.sh
CHANGED
|
@@ -52,7 +52,7 @@ try:
|
|
| 52 |
except Exception:
|
| 53 |
d = {}
|
| 54 |
d['\$schema'] = 'https://opencode.ai/config.json'
|
| 55 |
-
d['server'] =
|
| 56 |
d['provider'] = d.get('provider', {})
|
| 57 |
d['provider']['omniroute'] = {
|
| 58 |
'name': 'OmniRoute Gateway',
|
|
@@ -163,6 +163,9 @@ else
|
|
| 163 |
fi
|
| 164 |
|
| 165 |
echo "============================================"
|
| 166 |
-
echo "=== Launching OpenCode server ==="
|
| 167 |
echo "============================================"
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
except Exception:
|
| 53 |
d = {}
|
| 54 |
d['\$schema'] = 'https://opencode.ai/config.json'
|
| 55 |
+
d['server'] = {'port': 4097, 'hostname': '127.0.0.1'}
|
| 56 |
d['provider'] = d.get('provider', {})
|
| 57 |
d['provider']['omniroute'] = {
|
| 58 |
'name': 'OmniRoute Gateway',
|
|
|
|
| 163 |
fi
|
| 164 |
|
| 165 |
echo "============================================"
|
| 166 |
+
echo "=== Launching OpenCode server & Nginx Proxy ==="
|
| 167 |
echo "============================================"
|
| 168 |
+
opencode serve --port 4097 --hostname 127.0.0.1 &
|
| 169 |
+
sleep 2
|
| 170 |
+
exec nginx -g "daemon off;" -c /nginx.conf
|
| 171 |
+
|
nginx.conf
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
events {
|
| 2 |
+
worker_connections 1024;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
http {
|
| 6 |
+
include /etc/nginx/mime.types;
|
| 7 |
+
default_type application/octet-stream;
|
| 8 |
+
sendfile on;
|
| 9 |
+
|
| 10 |
+
server {
|
| 11 |
+
listen 4096;
|
| 12 |
+
|
| 13 |
+
# Route to OmniRoute Dashboard & API
|
| 14 |
+
location /omniroute/ {
|
| 15 |
+
proxy_pass http://127.0.0.1:20128/;
|
| 16 |
+
proxy_http_version 1.1;
|
| 17 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 18 |
+
proxy_set_header Connection "upgrade";
|
| 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 |
+
}
|
| 24 |
+
|
| 25 |
+
# Default route to OpenCode Server
|
| 26 |
+
location / {
|
| 27 |
+
proxy_pass http://127.0.0.1:4097;
|
| 28 |
+
proxy_http_version 1.1;
|
| 29 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 30 |
+
proxy_set_header Connection "upgrade";
|
| 31 |
+
proxy_set_header Host $host;
|
| 32 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 33 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 34 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
}
|