Spaces:
Sleeping
Sleeping
new dockerfile
Browse files- Dockerfile +31 -0
- aiproxy/__main__.py +7 -6
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 AS dev
|
2 |
+
|
3 |
+
RUN apt-get update -y \
|
4 |
+
&& apt-get install -y python3-pip git
|
5 |
+
|
6 |
+
WORKDIR /workspace
|
7 |
+
|
8 |
+
# install build and runtime dependencies
|
9 |
+
COPY requirements.txt requirements.txt
|
10 |
+
COPY aiproxy aiproxy
|
11 |
+
|
12 |
+
RUN --mount=type=cache,target=/root/.cache/pip \
|
13 |
+
pip install -r requirements.txt
|
14 |
+
|
15 |
+
# Create a non-root user
|
16 |
+
RUN useradd -m appuser
|
17 |
+
|
18 |
+
# Transfer ownership of the /workspace to the new non-root user
|
19 |
+
RUN chown -R appuser:appuser /workspace
|
20 |
+
|
21 |
+
# Create a cache directory within the appuser's home directory and transfer ownership
|
22 |
+
RUN mkdir -p /home/appuser/cache && \
|
23 |
+
chown -R appuser:appuser /home/appuser/cache
|
24 |
+
|
25 |
+
# Switch to the non-root user for subsequent commands and container runtime
|
26 |
+
USER appuser
|
27 |
+
|
28 |
+
CMD ["python3", "-m", \
|
29 |
+
"aiproxy", \
|
30 |
+
"--host", "0.0.0.0", \
|
31 |
+
"--port", "7860"]
|
aiproxy/__main__.py
CHANGED
@@ -8,15 +8,16 @@ from aiproxy.accesslog import AccessLogWorker
|
|
8 |
import threading
|
9 |
import uvicorn
|
10 |
|
11 |
-
# Get API Key from env
|
12 |
-
|
|
|
13 |
|
14 |
# Get arguments
|
15 |
parser = argparse.ArgumentParser(description="UnaProxy usage")
|
16 |
-
parser.add_argument("--host", type=str, default=None, required=
|
17 |
-
parser.add_argument("--port", type=int, default=None, required=
|
18 |
-
parser.add_argument("--base_url", type=str, default=
|
19 |
-
parser.add_argument("--openai_api_key", type=str, default=
|
20 |
args = parser.parse_args()
|
21 |
|
22 |
# Setup logger
|
|
|
8 |
import threading
|
9 |
import uvicorn
|
10 |
|
11 |
+
# Get Base URL and API Key from env
|
12 |
+
base_url = os.environ.get("BASE_URL")
|
13 |
+
env_api_key = os.environ.get("API_KEY")
|
14 |
|
15 |
# Get arguments
|
16 |
parser = argparse.ArgumentParser(description="UnaProxy usage")
|
17 |
+
parser.add_argument("--host", type=str, default=None, required=False, help="hostname or ipaddress")
|
18 |
+
parser.add_argument("--port", type=int, default=None, required=False, help="port number")
|
19 |
+
parser.add_argument("--base_url", type=str, default=base_url, required=False, help="port number")
|
20 |
+
parser.add_argument("--openai_api_key", type=str, default=env_api_key, required=False, help="OpenAI API Key")
|
21 |
args = parser.parse_args()
|
22 |
|
23 |
# Setup logger
|