Spaces:
Sleeping
Sleeping
kidcoconut
commited on
Commit
•
851f5e5
0
Parent(s):
orphan: clean tree ready for push to hugspace
Browse files- Dockerfile +82 -0
- README.md +21 -0
- _env_config/stg_dev/utl_dkr_preRun.sh +38 -0
- fastapi/ABOUTME.md +6 -0
- fastapi/entry_fastapi.py +159 -0
- gradio/ABOUTME.md +6 -0
- nginx/etc.nginx.confd_default.conf +94 -0
- nginx/etc.nginx.sites-available.default +91 -0
- nginx/etc.nginx_nginx.conf +86 -0
- requirements.txt +111 -0
- streamlit/ABOUTME.md +6 -0
- streamlit/entry_streamlit.py +23 -0
Dockerfile
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#--- PREREQS:
|
2 |
+
# - https://huggingface.co/spaces/radames/nginx-gradio-reverse-proxy/tree/main
|
3 |
+
# - https://muellerzr.github.io/blog/huggingface_docker.html
|
4 |
+
# - https://www.tecmint.com/enable-nginx-status-page/
|
5 |
+
|
6 |
+
#--- USAGE:
|
7 |
+
#--- to build/rebuild the image; make sure you stop and remove the container if you are replacing/upgrading; or change the version tag# from 0.0.1
|
8 |
+
#--- to tag the image prior to push to DockerHub; docker login and then register user/image:tag
|
9 |
+
#--- to push this image to DockerHub, example based on the repo: kidcoconut73/<img>
|
10 |
+
|
11 |
+
# docker build -t img_nginx_hugspace:0.0.1 .
|
12 |
+
# docker create -it -p 49130:39130 --name ctr_nginx_hugspace img_nginx_hugspace:0.0.1
|
13 |
+
# docker start -it ctr_nginx_hugspace
|
14 |
+
|
15 |
+
# docker run -it -p 7860:7860 -p 49131:39131 -p 49132:39132 --name ctr_nginx_templ img_nginx_templ:0.0.1
|
16 |
+
|
17 |
+
# docker push kidcoconut73/<img:tag>
|
18 |
+
|
19 |
+
|
20 |
+
#--- use a base image of python
|
21 |
+
FROM python:3.8-slim-buster
|
22 |
+
|
23 |
+
|
24 |
+
# Install nginx and give permissions to 'pn'
|
25 |
+
# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
|
26 |
+
USER root
|
27 |
+
|
28 |
+
#$ apt list --installed | grep nginx; 1.22.1-9
|
29 |
+
RUN apt-get -y update && apt-get -y install nginx
|
30 |
+
|
31 |
+
RUN mkdir -p /var/cache/nginx \
|
32 |
+
/var/log/nginx \
|
33 |
+
/var/lib/nginx
|
34 |
+
RUN touch /var/run/nginx.pid
|
35 |
+
|
36 |
+
RUN groupadd user
|
37 |
+
RUN useradd -d /home/user -ms /bin/bash -g user -G user -p user user
|
38 |
+
RUN chown -R user:user /var/cache/nginx \
|
39 |
+
/var/log/nginx \
|
40 |
+
/var/lib/nginx \
|
41 |
+
/var/run/nginx.pid
|
42 |
+
|
43 |
+
#--- update nginx config; establish routes/proxy pass; remove user directive
|
44 |
+
COPY ./nginx/etc.nginx.confd_default.conf /etc/nginx/conf.d/default.conf
|
45 |
+
COPY ./nginx/etc.nginx_nginx.conf /etc/nginx/nginx.conf
|
46 |
+
#COPY ./nginx/etc.nginx.sites-available.default /etc/nginx/sites-available/default
|
47 |
+
|
48 |
+
|
49 |
+
#--- Install dependencies and build app as non-root
|
50 |
+
USER user
|
51 |
+
ENV HOME=/home/user \
|
52 |
+
PATH=/home/user/.local/bin:$PATH
|
53 |
+
|
54 |
+
#--- set docker image working directory to /app
|
55 |
+
RUN mkdir $HOME/app
|
56 |
+
WORKDIR $HOME/app
|
57 |
+
|
58 |
+
#--- install all lib dependencies into the image
|
59 |
+
COPY --chown=user ./requirements.txt ./requirements.txt
|
60 |
+
RUN pip install --no-cache-dir -r ./requirements.txt
|
61 |
+
|
62 |
+
#--- copy files from the local pwd to the docker image /app folder
|
63 |
+
#--- .dockerignore: ensure no local data folders or files (images) are copied into the docker image/container
|
64 |
+
COPY --chown=user ./_env_config/stg_dev/utl_dkr_preRun.sh ./scripts/docker/
|
65 |
+
COPY --chown=user ./fastapi ./fastapi
|
66 |
+
COPY --chown=user ./gradio ./gradio
|
67 |
+
COPY --chown=user ./streamlit ./streamlit
|
68 |
+
|
69 |
+
#--- for nginx reverse proxy; external 49130; internal 39130
|
70 |
+
#--- for streamlit; external 49131; internal 39131
|
71 |
+
#--- for fastapi; external 49132; internal 39132
|
72 |
+
#--- for huggingface; assume 1:1 mapping between internal and external ports; and only one port can truly be exposed
|
73 |
+
EXPOSE 7860
|
74 |
+
EXPOSE 49131
|
75 |
+
EXPOSE 49132
|
76 |
+
|
77 |
+
#--- establish environment prereqs
|
78 |
+
#CMD ls -la /app/scripts/docker
|
79 |
+
ENTRYPOINT [ "./scripts/docker/utl_dkr_preRun.sh" ]
|
80 |
+
|
81 |
+
|
82 |
+
#--- WORKAROUND: you may have to stop the docker container through docker desktop, or cmd line eg docker kill <ctr_name>
|
README.md
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: spcdkr nginx templ
|
3 |
+
emoji: 📉
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: pink
|
6 |
+
sdk: docker
|
7 |
+
app_port: 7860
|
8 |
+
pinned: false
|
9 |
+
license: mit
|
10 |
+
---
|
11 |
+
|
12 |
+
This app is publically available and run at https://kidcoconut-dkr-nginx-templ.hf.space/
|
13 |
+
example endpoint:  https://kidcoconut-dkr-fastapi-templ.hf.space/sanity
|
14 |
+
example endpoint:  https://kidcoconut-dkr-fastapi-templ.hf.space/syscheck/sanity
|
15 |
+
|
16 |
+
streamlit endpoint:  https://kidcoconut-dkr-nginx-templ.hf.space/  [web | streamlit]
|
17 |
+
fastapi endpoint:   https://kidcoconut-dkr-nginx-templ.hf.space/api  [api | fastapi]
|
18 |
+
gradio:       https://kidcoconut-dkr-nginx-templ.hf.space/gradio
|
19 |
+
docs:        https://kidcoconut-dkr-nginx-templ.hf.space/docs
|
20 |
+
|
21 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
_env_config/stg_dev/utl_dkr_preRun.sh
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
#--- Note: this file is designed to run locally as well as within docker to prep the environment
|
4 |
+
#--- Entry: this script is assumed to run from the /app root folder
|
5 |
+
#--- Usage: ./_env_config/local_dev/utl_dkr_preRun.sh
|
6 |
+
|
7 |
+
#--- for volume initialization; ensure folders are in place; assume: we are in the /app folder
|
8 |
+
|
9 |
+
|
10 |
+
<<blockComment
|
11 |
+
-
|
12 |
+
blockComment
|
13 |
+
echo -e "INFO(utl_dkr_preRun):\t Initializing ..."
|
14 |
+
|
15 |
+
strpth_pwd=$(pwd)
|
16 |
+
strpth_scriptLoc=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
17 |
+
strpth_scrHome="${strpth_scriptLoc}/../"
|
18 |
+
strpth_appHome="${strpth_scrHome}../"
|
19 |
+
strpth_scrModels="${strpth_scrHome}models/"
|
20 |
+
|
21 |
+
#echo "strpth_appHome = ${strpth_appHome}"
|
22 |
+
|
23 |
+
#--- for nginx; external 7860; internal 7860
|
24 |
+
service nginx start
|
25 |
+
|
26 |
+
#--- for fastapi; external 49132; internal 39132
|
27 |
+
echo "INFO: starting fastapi ..."
|
28 |
+
uvicorn --app-dir=./fastapi entry_fastapi:app --reload --workers 1 --host 0.0.0.0 --port 39132 & #--- specify a non-root app dir
|
29 |
+
|
30 |
+
|
31 |
+
#--- for streamlit; external 49131; internal 39131
|
32 |
+
echo "INFO: starting streamlit ..."
|
33 |
+
streamlit run ./streamlit/entry_streamlit.py --server.port=39131 --server.maxUploadSize=2000 #--- & run in the background
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
<<blockErrorLog
|
38 |
+
blockErrorLog
|
fastapi/ABOUTME.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ABOUTME: fastapi
|
2 |
+
## Purpose: this environment is used to API endpoints
|
3 |
+
## Prereq:
|
4 |
+
## -
|
5 |
+
|
6 |
+
|
fastapi/entry_fastapi.py
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
purpose: fastAPI routing
|
3 |
+
|
4 |
+
refs:
|
5 |
+
fast api behind proxy/root_path: https://fastapi.tiangolo.com/advanced/behind-a-proxy/
|
6 |
+
'''
|
7 |
+
|
8 |
+
from fastapi import FastAPI
|
9 |
+
from fastapi.responses import HTMLResponse, RedirectResponse
|
10 |
+
from fastapi import APIRouter, Request, Response
|
11 |
+
from fastapi.templating import Jinja2Templates
|
12 |
+
import uvicorn
|
13 |
+
import gradio as gr
|
14 |
+
|
15 |
+
#--- import custom libraries
|
16 |
+
#import lib.utils as libUtils
|
17 |
+
|
18 |
+
|
19 |
+
#--- imported route handlers
|
20 |
+
#from routes.api.rte_api import rteApi
|
21 |
+
|
22 |
+
|
23 |
+
#--- fastAPI self doc descriptors
|
24 |
+
description = """
|
25 |
+
Prototype: FastApi in Docker on Huggingface
|
26 |
+
|
27 |
+
<insert purpose>
|
28 |
+
|
29 |
+
## key business benefit #1
|
30 |
+
## key business benefit #2
|
31 |
+
## key business benefit #3
|
32 |
+
|
33 |
+
You will be able to:
|
34 |
+
* key feature #1
|
35 |
+
* key feature #2
|
36 |
+
* key feature #3
|
37 |
+
"""
|
38 |
+
|
39 |
+
#--- main fast api app
|
40 |
+
app = FastAPI(
|
41 |
+
title="Prototype: Fastapi in docker",
|
42 |
+
description=description,
|
43 |
+
version="0.0.1",
|
44 |
+
terms_of_service="http://example.com/terms/",
|
45 |
+
contact={
|
46 |
+
"name": "Iain McKone",
|
47 |
+
"email": "iain.mckone@gmail.com",
|
48 |
+
},
|
49 |
+
license_info={
|
50 |
+
"name": "MIT",
|
51 |
+
"url": "http://opensource.org/licenses/MIT",
|
52 |
+
},
|
53 |
+
openapi_url="/api/v1/openapi.json"
|
54 |
+
)
|
55 |
+
|
56 |
+
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
57 |
+
app = gr.mount_gradio_app(app, io, path="/gradio_svc")
|
58 |
+
|
59 |
+
|
60 |
+
#--- configure route handlers
|
61 |
+
#app.include_router(rteApi, prefix="/api")
|
62 |
+
#app.include_router(rteQa, prefix="/qa")
|
63 |
+
|
64 |
+
|
65 |
+
#m_kstrPath_templ = libUtils.pth_templ
|
66 |
+
#m_templRef = Jinja2Templates(directory=str(m_kstrPath_templ))
|
67 |
+
|
68 |
+
|
69 |
+
""" def get_jinja2Templ(request: Request, pdfResults, strParamTitle, lngNumRecords, blnIsTrain=False, blnIsSample=False):
|
70 |
+
lngNumRecords = min(lngNumRecords, libUtils.m_klngMaxRecords)
|
71 |
+
if (blnIsTrain): strParamTitle = strParamTitle + " - Training Data"
|
72 |
+
if (not blnIsTrain): strParamTitle = strParamTitle + " - Test Data"
|
73 |
+
if (blnIsSample): lngNumRecords = libUtils.m_klngSampleSize
|
74 |
+
strParamTitle = strParamTitle + " - max " + str(lngNumRecords) + " rows"
|
75 |
+
|
76 |
+
kstrTempl = 'templ_showDataframe.html'
|
77 |
+
jsonContext = {'request': request,
|
78 |
+
'paramTitle': strParamTitle,
|
79 |
+
'paramDataframe': pdfResults.sample(lngNumRecords).to_html(classes='table table-striped')
|
80 |
+
}
|
81 |
+
result = m_templRef.TemplateResponse(kstrTempl, jsonContext)
|
82 |
+
return result """
|
83 |
+
|
84 |
+
|
85 |
+
#--- get main ui/ux entry point
|
86 |
+
@app.get('/')
|
87 |
+
def index():
|
88 |
+
|
89 |
+
return {
|
90 |
+
"message": "Landing page: prototype for fastApi"
|
91 |
+
}
|
92 |
+
|
93 |
+
@app.get('/api')
|
94 |
+
def rte_api():
|
95 |
+
|
96 |
+
return {
|
97 |
+
"message": "Landing page: prototype for fastApi"
|
98 |
+
}
|
99 |
+
|
100 |
+
@app.get('/gradio')
|
101 |
+
def rte_gradio():
|
102 |
+
|
103 |
+
#return {
|
104 |
+
# "message": "Landing page: this is where gradio would start from if we could mount with fastapi"
|
105 |
+
#}
|
106 |
+
return RedirectResponse("/gradio_svc")
|
107 |
+
|
108 |
+
|
109 |
+
@app.get('/streamlit')
|
110 |
+
def rte_streamlit():
|
111 |
+
|
112 |
+
return {
|
113 |
+
"message": "Landing page: this is where streamlit would start from if we could mount with fastapi"
|
114 |
+
}
|
115 |
+
|
116 |
+
@app.get('/shiny')
|
117 |
+
def rte_shiny():
|
118 |
+
|
119 |
+
return {
|
120 |
+
"message": "Landing page: this is where shiny would start mounted with fastapi"
|
121 |
+
}
|
122 |
+
|
123 |
+
@app.get('/syscheck/{check_id}')
|
124 |
+
async def syscheck(check_id: str):
|
125 |
+
from os import system
|
126 |
+
#import commands
|
127 |
+
|
128 |
+
print("TRACE: fastapi.syscheck ... {check_id} ", check_id)
|
129 |
+
|
130 |
+
if (check_id=='apt_list'):
|
131 |
+
print("TRACE: fastapi.syscheck ... {apt_list} ")
|
132 |
+
m_sysMsg = system("apt list --installed")
|
133 |
+
return {"message: syscheck apt list complete " + str(m_sysMsg)}
|
134 |
+
|
135 |
+
elif (check_id=='sanity'):
|
136 |
+
print("TRACE: fastapi.syscheck ... {}".format(check_id))
|
137 |
+
return {"message: syscheck sanity ... ok "}
|
138 |
+
|
139 |
+
elif (check_id=='pip_list'):
|
140 |
+
print("TRACE: fastapi.syscheck ... {pip_list} ")
|
141 |
+
m_sysMsg = system("pip list")
|
142 |
+
return {"message: syscheck pip list complete " + str(m_sysMsg)}
|
143 |
+
|
144 |
+
else:
|
145 |
+
return {"message": "fastApi: syscheck {check_id} " + check_id}
|
146 |
+
|
147 |
+
|
148 |
+
@app.get('/sanity')
|
149 |
+
async def sanity():
|
150 |
+
print("TRACE: fastapi.sanity ... {}")
|
151 |
+
return {"message: syscheck sanity ... ok "}
|
152 |
+
|
153 |
+
|
154 |
+
if __name__ == '__main__':
|
155 |
+
#uvicorn.run("main:app", host="0.0.0.0", port=49132, reload=True)
|
156 |
+
#uvicorn --app-dir=./fastapi entry_fastapi:app --reload --workers 1 --host 0.0.0.0 --port 7860 & #--- specify a non-root app dir
|
157 |
+
uvicorn.run("fastapi.entry_fastapi:app", reload=True, workers=1, host="0.0.0.0", port=49132)
|
158 |
+
#CMD ["uvicorn", "main:app", "--host=0.0.0.0", "--reload"]
|
159 |
+
|
gradio/ABOUTME.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ABOUTME: gradio
|
2 |
+
## Purpose: this environment is used to host a gradio UI
|
3 |
+
## Prereq:
|
4 |
+
## -
|
5 |
+
|
6 |
+
|
nginx/etc.nginx.confd_default.conf
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
server {
|
2 |
+
#listen 80;
|
3 |
+
listen 7860;
|
4 |
+
server_name localhost;
|
5 |
+
|
6 |
+
#access_log /var/log/nginx/host.access.log main;
|
7 |
+
|
8 |
+
#--- Note: we have a basic web server with entry points and routes
|
9 |
+
|
10 |
+
|
11 |
+
#--- streamlit
|
12 |
+
location / {
|
13 |
+
proxy_pass http://127.0.0.1:39131/; #--- default streamlit landing page
|
14 |
+
proxy_http_version 1.1;
|
15 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
16 |
+
proxy_set_header Host $host;
|
17 |
+
proxy_set_header Upgrade $http_upgrade;
|
18 |
+
proxy_set_header Connection "upgrade";
|
19 |
+
proxy_read_timeout 86400;
|
20 |
+
}
|
21 |
+
location ~ ^/(streamlit|web)/ {
|
22 |
+
rewrite ^/streamlit/(.*) /$1 last;
|
23 |
+
rewrite ^/web/(.*) /$1 last;
|
24 |
+
return 403;
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
#--- fastapi
|
29 |
+
#--- WARN: the below combined OR directive does not work
|
30 |
+
#location ~ ^/(api|fastapi|api2|fastapi2)/
|
31 |
+
location /api/ {
|
32 |
+
proxy_pass http://127.0.0.1:39132/; #--- default fastapi landing page
|
33 |
+
proxy_buffering off;
|
34 |
+
proxy_set_header X-Real-IP $remote_addr;
|
35 |
+
proxy_set_header X-Forwarded-Host $host;
|
36 |
+
proxy_set_header X-Forwarded-Port $server_port;
|
37 |
+
}
|
38 |
+
location ~ ^/(fastapi|api2|fastapi2)/ {
|
39 |
+
rewrite ^/fastapi/(.*) /api/$1 last;
|
40 |
+
rewrite ^/api2/(.*) /api/$1 last;
|
41 |
+
rewrite ^/fastapi2/(.*) /api/$1 last;
|
42 |
+
return 403;
|
43 |
+
}
|
44 |
+
|
45 |
+
#--- gradio
|
46 |
+
location /gradio/ {
|
47 |
+
proxy_pass http://127.0.0.1:39133/; #--- default gradio landing page
|
48 |
+
proxy_buffering off;
|
49 |
+
proxy_set_header X-Real-IP $remote_addr;
|
50 |
+
proxy_set_header X-Forwarded-Host $host;
|
51 |
+
proxy_set_header X-Forwarded-Port $server_port;
|
52 |
+
}
|
53 |
+
|
54 |
+
#location /admin/nginx/ {
|
55 |
+
# #rewrite ^(/download/.*)/media/(\w+)\.?.*$ $1/mp3/$2.mp3 last;
|
56 |
+
# #return 403;
|
57 |
+
#
|
58 |
+
# root /usr/share/nginx/html;
|
59 |
+
# index index.html index.htm;
|
60 |
+
#}
|
61 |
+
|
62 |
+
#error_page 404 /404.html;
|
63 |
+
|
64 |
+
# redirect server error pages to the static page /50x.html
|
65 |
+
#
|
66 |
+
error_page 500 502 503 504 /50x.html;
|
67 |
+
location = /50x.html {
|
68 |
+
root /usr/share/nginx/html;
|
69 |
+
}
|
70 |
+
|
71 |
+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
72 |
+
#
|
73 |
+
#location ~ \.php$ {
|
74 |
+
# proxy_pass http://127.0.0.1;
|
75 |
+
#}
|
76 |
+
|
77 |
+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
78 |
+
#
|
79 |
+
#location ~ \.php$ {
|
80 |
+
# root html;
|
81 |
+
# fastcgi_pass 127.0.0.1:9000;
|
82 |
+
# fastcgi_index index.php;
|
83 |
+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
84 |
+
# include fastcgi_params;
|
85 |
+
#}
|
86 |
+
|
87 |
+
# deny access to .htaccess files, if Apache's document root
|
88 |
+
# concurs with nginx's one
|
89 |
+
#
|
90 |
+
#location ~ /\.ht {
|
91 |
+
# deny all;
|
92 |
+
#}
|
93 |
+
}
|
94 |
+
|
nginx/etc.nginx.sites-available.default
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##
|
2 |
+
# You should look at the following URL's in order to grasp a solid understanding
|
3 |
+
# of Nginx configuration files in order to fully unleash the power of Nginx.
|
4 |
+
# https://www.nginx.com/resources/wiki/start/
|
5 |
+
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
|
6 |
+
# https://wiki.debian.org/Nginx/DirectoryStructure
|
7 |
+
#
|
8 |
+
# In most cases, administrators will remove this file from sites-enabled/ and
|
9 |
+
# leave it as reference inside of sites-available where it will continue to be
|
10 |
+
# updated by the nginx packaging team.
|
11 |
+
#
|
12 |
+
# This file will automatically load configuration files provided by other
|
13 |
+
# applications, such as Drupal or Wordpress. These applications will be made
|
14 |
+
# available underneath a path with that package name, such as /drupal8.
|
15 |
+
#
|
16 |
+
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
|
17 |
+
##
|
18 |
+
|
19 |
+
# Default server configuration
|
20 |
+
#
|
21 |
+
server {
|
22 |
+
listen 80 default_server;
|
23 |
+
#listen [::]:80 default_server; #--- IM: disable ipv6 dependency
|
24 |
+
|
25 |
+
# SSL configuration
|
26 |
+
#
|
27 |
+
# listen 443 ssl default_server;
|
28 |
+
# listen [::]:443 ssl default_server;
|
29 |
+
#
|
30 |
+
# Note: You should disable gzip for SSL traffic.
|
31 |
+
# See: https://bugs.debian.org/773332
|
32 |
+
#
|
33 |
+
# Read up on ssl_ciphers to ensure a secure configuration.
|
34 |
+
# See: https://bugs.debian.org/765782
|
35 |
+
#
|
36 |
+
# Self signed certs generated by the ssl-cert package
|
37 |
+
# Don't use them in a production server!
|
38 |
+
#
|
39 |
+
# include snippets/snakeoil.conf;
|
40 |
+
|
41 |
+
root /var/www/html;
|
42 |
+
|
43 |
+
# Add index.php to the list if you are using PHP
|
44 |
+
index index.html index.htm index.nginx-debian.html;
|
45 |
+
|
46 |
+
server_name _;
|
47 |
+
|
48 |
+
location / {
|
49 |
+
# First attempt to serve request as file, then
|
50 |
+
# as directory, then fall back to displaying a 404.
|
51 |
+
try_files $uri $uri/ =404;
|
52 |
+
}
|
53 |
+
|
54 |
+
# pass PHP scripts to FastCGI server
|
55 |
+
#
|
56 |
+
#location ~ \.php$ {
|
57 |
+
# include snippets/fastcgi-php.conf;
|
58 |
+
#
|
59 |
+
# # With php-fpm (or other unix sockets):
|
60 |
+
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
61 |
+
# # With php-cgi (or other tcp sockets):
|
62 |
+
# fastcgi_pass 127.0.0.1:9000;
|
63 |
+
#}
|
64 |
+
|
65 |
+
# deny access to .htaccess files, if Apache's document root
|
66 |
+
# concurs with nginx's one
|
67 |
+
#
|
68 |
+
#location ~ /\.ht {
|
69 |
+
# deny all;
|
70 |
+
#}
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
# Virtual Host configuration for example.com
|
75 |
+
#
|
76 |
+
# You can move that to a different file under sites-available/ and symlink that
|
77 |
+
# to sites-enabled/ to enable it.
|
78 |
+
#
|
79 |
+
#server {
|
80 |
+
# listen 80;
|
81 |
+
# listen [::]:80;
|
82 |
+
#
|
83 |
+
# server_name example.com;
|
84 |
+
#
|
85 |
+
# root /var/www/example.com;
|
86 |
+
# index index.html;
|
87 |
+
#
|
88 |
+
# location / {
|
89 |
+
# try_files $uri $uri/ =404;
|
90 |
+
# }
|
91 |
+
#}
|
nginx/etc.nginx_nginx.conf
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#--- 20240627: remove user directive in attempt to get nginx to run alognside streamlit and fastapi
|
2 |
+
#user www-data;
|
3 |
+
worker_processes auto;
|
4 |
+
pid /run/nginx.pid;
|
5 |
+
include /etc/nginx/modules-enabled/*.conf;
|
6 |
+
|
7 |
+
events {
|
8 |
+
worker_connections 768;
|
9 |
+
# multi_accept on;
|
10 |
+
}
|
11 |
+
|
12 |
+
http {
|
13 |
+
|
14 |
+
##
|
15 |
+
# Basic Settings
|
16 |
+
##
|
17 |
+
|
18 |
+
sendfile on;
|
19 |
+
tcp_nopush on;
|
20 |
+
tcp_nodelay on;
|
21 |
+
keepalive_timeout 65;
|
22 |
+
types_hash_max_size 2048;
|
23 |
+
# server_tokens off;
|
24 |
+
|
25 |
+
# server_names_hash_bucket_size 64;
|
26 |
+
# server_name_in_redirect off;
|
27 |
+
|
28 |
+
include /etc/nginx/mime.types;
|
29 |
+
default_type application/octet-stream;
|
30 |
+
|
31 |
+
##
|
32 |
+
# SSL Settings
|
33 |
+
##
|
34 |
+
|
35 |
+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
36 |
+
ssl_prefer_server_ciphers on;
|
37 |
+
|
38 |
+
##
|
39 |
+
# Logging Settings
|
40 |
+
##
|
41 |
+
|
42 |
+
access_log /var/log/nginx/access.log;
|
43 |
+
error_log /var/log/nginx/error.log;
|
44 |
+
|
45 |
+
##
|
46 |
+
# Gzip Settings
|
47 |
+
##
|
48 |
+
|
49 |
+
gzip on;
|
50 |
+
|
51 |
+
# gzip_vary on;
|
52 |
+
# gzip_proxied any;
|
53 |
+
# gzip_comp_level 6;
|
54 |
+
# gzip_buffers 16 8k;
|
55 |
+
# gzip_http_version 1.1;
|
56 |
+
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
57 |
+
|
58 |
+
##
|
59 |
+
# Virtual Host Configs
|
60 |
+
##
|
61 |
+
|
62 |
+
include /etc/nginx/conf.d/*.conf; #--- IM: check what *.conf files exist here
|
63 |
+
#include /etc/nginx/sites-enabled/*; #--- IM: do not include these virtual sites; port 80 creates a problem
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
#mail {
|
68 |
+
# # See sample authentication script at:
|
69 |
+
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
|
70 |
+
#
|
71 |
+
# # auth_http localhost/auth.php;
|
72 |
+
# # pop3_capabilities "TOP" "USER";
|
73 |
+
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
|
74 |
+
#
|
75 |
+
# server {
|
76 |
+
# listen localhost:110;
|
77 |
+
# protocol pop3;
|
78 |
+
# proxy on;
|
79 |
+
# }
|
80 |
+
#
|
81 |
+
# server {
|
82 |
+
# listen localhost:143;
|
83 |
+
# protocol imap;
|
84 |
+
# proxy on;
|
85 |
+
# }
|
86 |
+
#}
|
requirements.txt
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
fastapi==0.111.0
|
3 |
+
gradio==4.37.2
|
4 |
+
shiny==0.10.2
|
5 |
+
streamlit==1.36.0
|
6 |
+
uvicorn==0.30.1
|
7 |
+
|
8 |
+
#--- 20240716: pip list on docker
|
9 |
+
#Package Version
|
10 |
+
#------------------------- -----------
|
11 |
+
#aiofiles 23.2.1
|
12 |
+
#altair 5.3.0
|
13 |
+
#annotated-types 0.7.0
|
14 |
+
#anyio 4.4.0
|
15 |
+
#appdirs 1.4.4
|
16 |
+
# asgiref 3.8.1
|
17 |
+
# attrs 23.2.0
|
18 |
+
# blinker 1.8.2
|
19 |
+
# cachetools 5.3.3
|
20 |
+
# certifi 2024.7.4
|
21 |
+
# charset-normalizer 3.3.2
|
22 |
+
# click 8.1.7
|
23 |
+
# contourpy 1.1.1
|
24 |
+
# cycler 0.12.1
|
25 |
+
# dnspython 2.6.1
|
26 |
+
# email_validator 2.2.0
|
27 |
+
# exceptiongroup 1.2.1
|
28 |
+
# fastapi 0.111.0
|
29 |
+
# fastapi-cli 0.0.4
|
30 |
+
# ffmpy 0.3.2
|
31 |
+
# filelock 3.15.4
|
32 |
+
# fonttools 4.53.1
|
33 |
+
# fsspec 2024.6.1
|
34 |
+
# gitdb 4.0.11
|
35 |
+
# GitPython 3.1.43
|
36 |
+
# gradio 4.37.2
|
37 |
+
# gradio_client 1.0.2
|
38 |
+
# h11 0.14.0
|
39 |
+
# htmltools 0.5.2
|
40 |
+
# httpcore 1.0.5
|
41 |
+
# httptools 0.6.1
|
42 |
+
# httpx 0.27.0
|
43 |
+
# huggingface-hub 0.23.4
|
44 |
+
# idna 3.7
|
45 |
+
# importlib_resources 6.4.0
|
46 |
+
# Jinja2 3.1.4
|
47 |
+
# jsonschema 4.23.0
|
48 |
+
# jsonschema-specifications 2023.12.1
|
49 |
+
# kiwisolver 1.4.5
|
50 |
+
# linkify-it-py 2.0.3
|
51 |
+
# markdown-it-py 3.0.0
|
52 |
+
# MarkupSafe 2.1.5
|
53 |
+
# matplotlib 3.7.5
|
54 |
+
# mdit-py-plugins 0.4.1
|
55 |
+
# mdurl 0.1.2
|
56 |
+
# numpy 1.24.4
|
57 |
+
# orjson 3.10.6
|
58 |
+
# packaging 24.1
|
59 |
+
# pandas 2.0.3
|
60 |
+
# pillow 10.4.0
|
61 |
+
# pip 23.0.1
|
62 |
+
# pkgutil_resolve_name 1.3.10
|
63 |
+
# prompt-toolkit 3.0.36
|
64 |
+
# protobuf 5.27.2
|
65 |
+
# pyarrow 16.1.0
|
66 |
+
# pydantic 2.8.2
|
67 |
+
# pydantic_core 2.20.1
|
68 |
+
# pydeck 0.9.1
|
69 |
+
# pydub 0.25.1
|
70 |
+
# Pygments 2.18.0
|
71 |
+
# pyparsing 3.1.2
|
72 |
+
# python-dateutil 2.9.0.post0
|
73 |
+
# python-dotenv 1.0.1
|
74 |
+
# python-multipart 0.0.9
|
75 |
+
# pytz 2024.1
|
76 |
+
# PyYAML 6.0.1
|
77 |
+
# questionary 2.0.1
|
78 |
+
# referencing 0.35.1
|
79 |
+
# requests 2.32.3
|
80 |
+
# rich 13.7.1
|
81 |
+
# rpds-py 0.19.0
|
82 |
+
# ruff 0.5.1
|
83 |
+
# semantic-version 2.10.0
|
84 |
+
# setuptools 57.5.0
|
85 |
+
# shellingham 1.5.4
|
86 |
+
# shiny 0.10.2
|
87 |
+
# six 1.16.0
|
88 |
+
# smmap 5.0.1
|
89 |
+
# sniffio 1.3.1
|
90 |
+
# starlette 0.37.2
|
91 |
+
# streamlit 1.36.0
|
92 |
+
# tenacity 8.5.0
|
93 |
+
# toml 0.10.2
|
94 |
+
# tomlkit 0.12.0
|
95 |
+
# toolz 0.12.1
|
96 |
+
# tornado 6.4.1
|
97 |
+
# tqdm 4.66.4
|
98 |
+
# typer 0.12.3
|
99 |
+
# typing_extensions 4.12.2
|
100 |
+
# tzdata 2024.1
|
101 |
+
# uc-micro-py 1.0.3
|
102 |
+
# ujson 5.10.0
|
103 |
+
# urllib3 2.2.2
|
104 |
+
# uvicorn 0.30.1
|
105 |
+
# uvloop 0.19.0
|
106 |
+
# watchdog 4.0.1
|
107 |
+
# watchfiles 0.22.0
|
108 |
+
# wcwidth 0.2.13
|
109 |
+
# websockets 11.0.3
|
110 |
+
# wheel 0.40.0
|
111 |
+
# zipp 3.19.2
|
streamlit/ABOUTME.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ABOUTME: streamlit
|
2 |
+
## Purpose: this environment is used to host a streamlit UI
|
3 |
+
## Prereq:
|
4 |
+
## -
|
5 |
+
|
6 |
+
|
streamlit/entry_streamlit.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
toExecute: (from root app folder) ... streamlit run entry_streamlit.py
|
3 |
+
'''
|
4 |
+
import streamlit as st
|
5 |
+
#import uix.lit_sidebar as litSideBar
|
6 |
+
|
7 |
+
|
8 |
+
#--- streamlit: specify title and logo
|
9 |
+
st.set_page_config(
|
10 |
+
page_title='Protoype - Fastapi with Streamlit Landing Page',
|
11 |
+
#page_icon='https://cdn.freebiesupply.com/logos/thumbs/1x/nvidia-logo.png',
|
12 |
+
layout="wide")
|
13 |
+
st.header('\
|
14 |
+
Protoyping Fastapi and Streamlit \
|
15 |
+
on Docker \
|
16 |
+
within Huggingface space \
|
17 |
+
')
|
18 |
+
#st.markdown("##### Iain McKone (Deployment Lead) [LinkedIn](%s)" % "https://linkedin.com/in/iainmckone")
|
19 |
+
st.markdown('---')
|
20 |
+
|
21 |
+
|
22 |
+
#--- streamlit: add a sidebar
|
23 |
+
#litSideBar.init()
|