Spaces:
Sleeping
Sleeping
Commit
·
1993c19
1
Parent(s):
2986659
Allowed for modification of server port, root path, max file size etc with environment variables.
Browse files- Dockerfile +6 -2
- README.md +1 -1
- app.py +14 -2
Dockerfile
CHANGED
|
@@ -14,12 +14,13 @@ WORKDIR /src
|
|
| 14 |
|
| 15 |
COPY requirements_aws.txt .
|
| 16 |
|
| 17 |
-
RUN
|
| 18 |
&& pip install --no-cache-dir --target=/install typing_extensions==4.12.2 \
|
| 19 |
&& pip install torch==2.5.1+cpu --target=/install --index-url https://download.pytorch.org/whl/cpu \
|
| 20 |
&& pip install --no-cache-dir --target=/install sentence-transformers==3.3.1 --no-deps \
|
| 21 |
&& pip install --no-cache-dir --target=/install -r requirements_aws.txt \
|
| 22 |
-
&& pip install --no-cache-dir --target=/install gradio==5.
|
|
|
|
| 23 |
|
| 24 |
# Add /install to the PYTHONPATH
|
| 25 |
ENV PYTHONPATH="/install:${PYTHONPATH}"
|
|
@@ -37,6 +38,9 @@ RUN useradd -m -u 1000 user
|
|
| 37 |
# Copy installed packages from builder stage
|
| 38 |
COPY --from=builder /install /usr/local/lib/python3.11/site-packages/
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
# Change ownership of /home/user directory
|
| 41 |
RUN chown -R user:user /home/user
|
| 42 |
|
|
|
|
| 14 |
|
| 15 |
COPY requirements_aws.txt .
|
| 16 |
|
| 17 |
+
RUN pip uninstall -y typing_extensions \
|
| 18 |
&& pip install --no-cache-dir --target=/install typing_extensions==4.12.2 \
|
| 19 |
&& pip install torch==2.5.1+cpu --target=/install --index-url https://download.pytorch.org/whl/cpu \
|
| 20 |
&& pip install --no-cache-dir --target=/install sentence-transformers==3.3.1 --no-deps \
|
| 21 |
&& pip install --no-cache-dir --target=/install -r requirements_aws.txt \
|
| 22 |
+
&& pip install --no-cache-dir --target=/install gradio==5.8.0
|
| 23 |
+
|
| 24 |
|
| 25 |
# Add /install to the PYTHONPATH
|
| 26 |
ENV PYTHONPATH="/install:${PYTHONPATH}"
|
|
|
|
| 38 |
# Copy installed packages from builder stage
|
| 39 |
COPY --from=builder /install /usr/local/lib/python3.11/site-packages/
|
| 40 |
|
| 41 |
+
# Check installed versions of typing_extensions
|
| 42 |
+
RUN pip list | grep typing_extensions
|
| 43 |
+
|
| 44 |
# Change ownership of /home/user directory
|
| 45 |
RUN chown -R user:user /home/user
|
| 46 |
|
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🔍
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.8.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
CHANGED
|
@@ -273,12 +273,24 @@ depends on factors such as the type of documents or queries. Information taken f
|
|
| 273 |
COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '0')
|
| 274 |
print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
if __name__ == "__main__":
|
| 277 |
|
| 278 |
if os.environ['COGNITO_AUTH'] == "1":
|
| 279 |
-
app.queue().launch(show_error=True, auth=authenticate_user)
|
| 280 |
else:
|
| 281 |
-
app.queue().launch(show_error=True, inbrowser=True)
|
| 282 |
|
| 283 |
# Running on local server with https: https://discuss.huggingface.co/t/how-to-run-gradio-with-0-0-0-0-and-https/38003 or https://dev.to/rajshirolkar/fastapi-over-https-for-development-on-windows-2p7d # Need to download OpenSSL and create own keys
|
| 284 |
# app.queue().launch(ssl_verify=False, share=False, debug=False, server_name="0.0.0.0",server_port=443,
|
|
|
|
| 273 |
COGNITO_AUTH = get_or_create_env_var('COGNITO_AUTH', '0')
|
| 274 |
print(f'The value of COGNITO_AUTH is {COGNITO_AUTH}')
|
| 275 |
|
| 276 |
+
MAX_QUEUE_SIZE = int(get_or_create_env_var('MAX_QUEUE_SIZE', '5'))
|
| 277 |
+
print(f'The value of RUN_DIRECT_MODE is {MAX_QUEUE_SIZE}')
|
| 278 |
+
|
| 279 |
+
MAX_FILE_SIZE = get_or_create_env_var('MAX_FILE_SIZE', '500mb')
|
| 280 |
+
print(f'The value of MAX_FILE_SIZE is {MAX_FILE_SIZE}')
|
| 281 |
+
|
| 282 |
+
GRADIO_SERVER_PORT = int(get_or_create_env_var('GRADIO_SERVER_PORT', '7860'))
|
| 283 |
+
print(f'The value of GRADIO_SERVER_PORT is {GRADIO_SERVER_PORT}')
|
| 284 |
+
|
| 285 |
+
ROOT_PATH = get_or_create_env_var('ROOT_PATH', '')
|
| 286 |
+
print(f'The value of ROOT_PATH is {ROOT_PATH}')
|
| 287 |
+
|
| 288 |
if __name__ == "__main__":
|
| 289 |
|
| 290 |
if os.environ['COGNITO_AUTH'] == "1":
|
| 291 |
+
app.queue(max_size=MAX_QUEUE_SIZE).launch(show_error=True, auth=authenticate_user, max_file_size=MAX_FILE_SIZE, server_port=GRADIO_SERVER_PORT, root_path=ROOT_PATH)
|
| 292 |
else:
|
| 293 |
+
app.queue(max_size=MAX_QUEUE_SIZE).launch(show_error=True, inbrowser=True, max_file_size=MAX_FILE_SIZE, server_port=GRADIO_SERVER_PORT, root_path=ROOT_PATH)
|
| 294 |
|
| 295 |
# Running on local server with https: https://discuss.huggingface.co/t/how-to-run-gradio-with-0-0-0-0-and-https/38003 or https://dev.to/rajshirolkar/fastapi-over-https-for-development-on-windows-2p7d # Need to download OpenSSL and create own keys
|
| 296 |
# app.queue().launch(ssl_verify=False, share=False, debug=False, server_name="0.0.0.0",server_port=443,
|