Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +2 -59
Dockerfile
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# Dockerfile
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
WORKDIR /app
|
|
@@ -6,7 +5,7 @@ WORKDIR /app
|
|
| 6 |
# Install nginx
|
| 7 |
RUN apt-get update && apt-get install -y nginx
|
| 8 |
|
| 9 |
-
# Copy requirements
|
| 10 |
COPY requirements.txt .
|
| 11 |
RUN pip install -r requirements.txt
|
| 12 |
|
|
@@ -16,66 +15,10 @@ COPY app.py .
|
|
| 16 |
# Copy nginx configuration
|
| 17 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 18 |
|
| 19 |
-
# Create nginx configuration with restricted CORS for elevatics.cloud
|
| 20 |
-
RUN echo 'events {
|
| 21 |
-
worker_connections 1024;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
http {
|
| 25 |
-
include /etc/nginx/mime.types;
|
| 26 |
-
default_type application/octet-stream;
|
| 27 |
-
|
| 28 |
-
upstream streamlit {
|
| 29 |
-
server localhost:8501;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
server {
|
| 33 |
-
listen 7860; # Changed from 80 to 7860
|
| 34 |
-
server_name localhost;
|
| 35 |
-
|
| 36 |
-
# Restricted CORS configuration for elevatics.cloud
|
| 37 |
-
add_header Access-Control-Allow-Origin "https://elevatics.cloud" always;
|
| 38 |
-
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
| 39 |
-
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always;
|
| 40 |
-
add_header X-Frame-Options "ALLOW-FROM https://elevatics.cloud" always;
|
| 41 |
-
add_header Content-Security-Policy "frame-ancestors https://elevatics.cloud" always;
|
| 42 |
-
|
| 43 |
-
# Handle OPTIONS method
|
| 44 |
-
if ($request_method = "OPTIONS") {
|
| 45 |
-
add_header Access-Control-Allow-Origin "https://elevatics.cloud" always;
|
| 46 |
-
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
| 47 |
-
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always;
|
| 48 |
-
add_header Access-Control-Max-Age 1728000;
|
| 49 |
-
add_header Content-Type text/plain;
|
| 50 |
-
add_header Content-Length 0;
|
| 51 |
-
return 204;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
location / {
|
| 55 |
-
proxy_pass http://streamlit;
|
| 56 |
-
proxy_set_header Host $host;
|
| 57 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 58 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 59 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
| 60 |
-
proxy_redirect off;
|
| 61 |
-
proxy_http_version 1.1;
|
| 62 |
-
proxy_set_header Upgrade $http_upgrade;
|
| 63 |
-
proxy_set_header Connection "upgrade";
|
| 64 |
-
|
| 65 |
-
# Additional security headers for iframe
|
| 66 |
-
add_header X-Frame-Options "ALLOW-FROM https://elevatics.cloud" always;
|
| 67 |
-
add_header Content-Security-Policy "frame-ancestors https://elevatics.cloud" always;
|
| 68 |
-
}
|
| 69 |
-
}
|
| 70 |
-
}' > /etc/nginx/nginx.conf
|
| 71 |
-
|
| 72 |
-
# Create requirements.txt
|
| 73 |
-
RUN echo 'streamlit==1.24.0\npandas==1.5.3\nnumpy==1.24.3' > requirements.txt
|
| 74 |
-
|
| 75 |
# Create start script
|
| 76 |
RUN echo '#!/bin/bash\nservice nginx start\nstreamlit run app.py' > start.sh
|
| 77 |
RUN chmod +x start.sh
|
| 78 |
|
| 79 |
-
EXPOSE 7860
|
| 80 |
|
| 81 |
CMD ["./start.sh"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
|
|
|
| 5 |
# Install nginx
|
| 6 |
RUN apt-get update && apt-get install -y nginx
|
| 7 |
|
| 8 |
+
# Copy requirements and install Python dependencies
|
| 9 |
COPY requirements.txt .
|
| 10 |
RUN pip install -r requirements.txt
|
| 11 |
|
|
|
|
| 15 |
# Copy nginx configuration
|
| 16 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Create start script
|
| 19 |
RUN echo '#!/bin/bash\nservice nginx start\nstreamlit run app.py' > start.sh
|
| 20 |
RUN chmod +x start.sh
|
| 21 |
|
| 22 |
+
EXPOSE 7860
|
| 23 |
|
| 24 |
CMD ["./start.sh"]
|