Yuvraj arora commited on
Commit ·
7d7b71c
1
Parent(s): 0ea17ce
Add nginx with main + test frontend
Browse files- Dockerfile +6 -1
- nginx.conf +4 -6
- test-frontend/index.html +12 -17
Dockerfile
CHANGED
|
@@ -1,12 +1,17 @@
|
|
| 1 |
FROM python:3.9
|
| 2 |
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
COPY requirements.txt .
|
| 6 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
|
| 8 |
COPY app.py .
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
EXPOSE 7860
|
| 11 |
|
| 12 |
-
CMD ["
|
|
|
|
| 1 |
FROM python:3.9
|
| 2 |
|
| 3 |
+
RUN apt update && apt install -y nginx && rm -rf /var/lib/apt/lists/*
|
| 4 |
+
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
COPY requirements.txt .
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
COPY app.py .
|
| 11 |
+
COPY site ./site
|
| 12 |
+
COPY test-frontend ./test-frontend
|
| 13 |
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 14 |
|
| 15 |
EXPOSE 7860
|
| 16 |
|
| 17 |
+
CMD ["sh", "-c", "nginx && uvicorn app:app --host 0.0.0.0 --port 7860"]
|
nginx.conf
CHANGED
|
@@ -3,13 +3,12 @@ server {
|
|
| 3 |
server_name hostify.yaspik.tech;
|
| 4 |
|
| 5 |
location / {
|
| 6 |
-
root /
|
| 7 |
index index.html;
|
| 8 |
-
try_files $uri $uri/ /index.html;
|
| 9 |
}
|
| 10 |
|
| 11 |
location /api/ {
|
| 12 |
-
proxy_pass http://127.0.0.1:
|
| 13 |
}
|
| 14 |
}
|
| 15 |
|
|
@@ -18,12 +17,11 @@ server {
|
|
| 18 |
server_name test.yaspik.tech;
|
| 19 |
|
| 20 |
location / {
|
| 21 |
-
root /
|
| 22 |
index index.html;
|
| 23 |
-
try_files $uri $uri/ /index.html;
|
| 24 |
}
|
| 25 |
|
| 26 |
location /api/ {
|
| 27 |
-
proxy_pass http://127.0.0.1:
|
| 28 |
}
|
| 29 |
}
|
|
|
|
| 3 |
server_name hostify.yaspik.tech;
|
| 4 |
|
| 5 |
location / {
|
| 6 |
+
root /app/site;
|
| 7 |
index index.html;
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
location /api/ {
|
| 11 |
+
proxy_pass http://127.0.0.1:7860;
|
| 12 |
}
|
| 13 |
}
|
| 14 |
|
|
|
|
| 17 |
server_name test.yaspik.tech;
|
| 18 |
|
| 19 |
location / {
|
| 20 |
+
root /app/test-frontend;
|
| 21 |
index index.html;
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
location /api/ {
|
| 25 |
+
proxy_pass http://127.0.0.1:7860;
|
| 26 |
}
|
| 27 |
}
|
test-frontend/index.html
CHANGED
|
@@ -1,17 +1,12 @@
|
|
| 1 |
-
<
|
| 2 |
-
<
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
<script src="app.js"></script>
|
| 15 |
-
</body>
|
| 16 |
-
|
| 17 |
-
</html>
|
|
|
|
| 1 |
+
<h1>🧪 Test Frontend</h1>
|
| 2 |
+
<button onclick="callApi()">Call API</button>
|
| 3 |
+
<pre id="out"></pre>
|
| 4 |
+
|
| 5 |
+
<script>
|
| 6 |
+
async function callApi() {
|
| 7 |
+
const res = await fetch("/api/health");
|
| 8 |
+
const data = await res.json();
|
| 9 |
+
document.getElementById("out").textContent =
|
| 10 |
+
JSON.stringify(data, null, 2);
|
| 11 |
+
}
|
| 12 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|