Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +15 -15
Dockerfile
CHANGED
|
@@ -1,24 +1,22 @@
|
|
| 1 |
# --- Stage 1: Runtime ---
|
| 2 |
FROM alpine:latest
|
| 3 |
|
| 4 |
-
# Install Nginx, Curl,
|
| 5 |
RUN apk add --no-cache nginx curl supervisor
|
| 6 |
|
| 7 |
# --- Install Chisel ---
|
| 8 |
-
# We download the official binary (Arch: amd64 for HF Spaces)
|
| 9 |
RUN curl -L -o /tmp/chisel.gz https://github.com/jpillora/chisel/releases/download/v1.9.1/chisel_1.9.1_linux_amd64.gz \
|
| 10 |
&& gzip -d /tmp/chisel.gz \
|
| 11 |
&& mv /tmp/chisel /usr/bin/chisel \
|
| 12 |
&& chmod +x /usr/bin/chisel
|
| 13 |
|
| 14 |
-
# Create
|
| 15 |
RUN adduser -D -u 1000 appuser
|
| 16 |
WORKDIR /home/appuser
|
| 17 |
|
| 18 |
# --- CONFIGURATION ---
|
| 19 |
|
| 20 |
# 1. Nginx Config
|
| 21 |
-
# This splits traffic: Normal users go to port 8080 (Your App), Tunnel goes to 7777 (Chisel)
|
| 22 |
RUN echo ' \
|
| 23 |
worker_processes auto; \
|
| 24 |
daemon off; \
|
|
@@ -45,7 +43,7 @@ http { \
|
|
| 45 |
server { \
|
| 46 |
listen 7860 default_server; \
|
| 47 |
\
|
| 48 |
-
#
|
| 49 |
location /_tunnel { \
|
| 50 |
proxy_pass http://127.0.0.1:7777/; \
|
| 51 |
proxy_http_version 1.1; \
|
|
@@ -54,7 +52,7 @@ http { \
|
|
| 54 |
proxy_read_timeout 86400; \
|
| 55 |
} \
|
| 56 |
\
|
| 57 |
-
#
|
| 58 |
location / { \
|
| 59 |
proxy_pass http://127.0.0.1:8080; \
|
| 60 |
proxy_set_header Host $host; \
|
|
@@ -64,23 +62,25 @@ http { \
|
|
| 64 |
} ' > /home/appuser/nginx.conf
|
| 65 |
|
| 66 |
# 2. Start Script
|
| 67 |
-
# Runs Nginx and Chisel Server
|
| 68 |
RUN echo "#!/bin/sh" > start.sh && \
|
| 69 |
echo "echo '--- Starting Chisel Server ---'" >> start.sh && \
|
| 70 |
-
echo "# --reverse allows clients to expose ports" >> start.sh && \
|
| 71 |
echo "chisel server --port 7777 --reverse &" >> start.sh && \
|
| 72 |
echo "echo '--- Starting Nginx ---'" >> start.sh && \
|
| 73 |
echo "nginx -c /home/appuser/nginx.conf &" >> start.sh && \
|
| 74 |
-
echo "echo '--- Running ---'" >> start.sh && \
|
| 75 |
echo "tail -f /dev/null" >> start.sh && \
|
| 76 |
chmod +x start.sh
|
| 77 |
|
| 78 |
-
# 3. Permissions
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
&& chown -R appuser:appuser /home/appuser \
|
| 85 |
&& chmod -R 777 /home/appuser
|
| 86 |
|
|
|
|
| 1 |
# --- Stage 1: Runtime ---
|
| 2 |
FROM alpine:latest
|
| 3 |
|
| 4 |
+
# Install Nginx, Curl, Supervisor
|
| 5 |
RUN apk add --no-cache nginx curl supervisor
|
| 6 |
|
| 7 |
# --- Install Chisel ---
|
|
|
|
| 8 |
RUN curl -L -o /tmp/chisel.gz https://github.com/jpillora/chisel/releases/download/v1.9.1/chisel_1.9.1_linux_amd64.gz \
|
| 9 |
&& gzip -d /tmp/chisel.gz \
|
| 10 |
&& mv /tmp/chisel /usr/bin/chisel \
|
| 11 |
&& chmod +x /usr/bin/chisel
|
| 12 |
|
| 13 |
+
# Create User
|
| 14 |
RUN adduser -D -u 1000 appuser
|
| 15 |
WORKDIR /home/appuser
|
| 16 |
|
| 17 |
# --- CONFIGURATION ---
|
| 18 |
|
| 19 |
# 1. Nginx Config
|
|
|
|
| 20 |
RUN echo ' \
|
| 21 |
worker_processes auto; \
|
| 22 |
daemon off; \
|
|
|
|
| 43 |
server { \
|
| 44 |
listen 7860 default_server; \
|
| 45 |
\
|
| 46 |
+
# The Tunnel Endpoint \
|
| 47 |
location /_tunnel { \
|
| 48 |
proxy_pass http://127.0.0.1:7777/; \
|
| 49 |
proxy_http_version 1.1; \
|
|
|
|
| 52 |
proxy_read_timeout 86400; \
|
| 53 |
} \
|
| 54 |
\
|
| 55 |
+
# The Public View \
|
| 56 |
location / { \
|
| 57 |
proxy_pass http://127.0.0.1:8080; \
|
| 58 |
proxy_set_header Host $host; \
|
|
|
|
| 62 |
} ' > /home/appuser/nginx.conf
|
| 63 |
|
| 64 |
# 2. Start Script
|
|
|
|
| 65 |
RUN echo "#!/bin/sh" > start.sh && \
|
| 66 |
echo "echo '--- Starting Chisel Server ---'" >> start.sh && \
|
|
|
|
| 67 |
echo "chisel server --port 7777 --reverse &" >> start.sh && \
|
| 68 |
echo "echo '--- Starting Nginx ---'" >> start.sh && \
|
| 69 |
echo "nginx -c /home/appuser/nginx.conf &" >> start.sh && \
|
| 70 |
+
echo "echo '--- Running. Waiting for client connection... ---'" >> start.sh && \
|
| 71 |
echo "tail -f /dev/null" >> start.sh && \
|
| 72 |
chmod +x start.sh
|
| 73 |
|
| 74 |
+
# 3. Permissions (The Fix for the log warning)
|
| 75 |
+
# We create the log directory and give ownership to appuser
|
| 76 |
+
RUN mkdir -p /var/lib/nginx/logs \
|
| 77 |
+
&& touch /var/lib/nginx/logs/error.log \
|
| 78 |
+
&& chown -R appuser:appuser /var/lib/nginx \
|
| 79 |
+
&& mkdir -p /home/appuser/client_body_temp \
|
| 80 |
+
/home/appuser/proxy_temp \
|
| 81 |
+
/home/appuser/fastcgi_temp \
|
| 82 |
+
/home/appuser/uwsgi_temp \
|
| 83 |
+
/home/appuser/scgi_temp \
|
| 84 |
&& chown -R appuser:appuser /home/appuser \
|
| 85 |
&& chmod -R 777 /home/appuser
|
| 86 |
|