shengwei62 commited on
Commit
656302b
1 Parent(s): 9c23dd9

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the custom FastAPI image
2
+ #FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
3
+ # Use ubuntu as base image
4
+ FROM ubuntu:22.04
5
+
6
+ # Avoid prompts from apt
7
+ ENV DEBIAN_FRONTEND=noninteractive
8
+
9
+ # Update apt repositories and install Python and Pip
10
+ RUN apt-get update && \
11
+ apt-get install -y python3-pip python3-dev
12
+
13
+ # Check if the symbolic links already exist and create them if they don't
14
+ RUN if [ ! -e /usr/bin/python ]; then ln -s /usr/bin/python3 /usr/bin/python; fi && \
15
+ if [ ! -e /usr/bin/pip ]; then ln -s /usr/bin/pip3 /usr/bin/pip; fi
16
+
17
+ # Set default values for environment variables
18
+ ENV OPENAI_ORG_ID=default_org_id
19
+ ENV OPENAI_API_KEY=default_api_key
20
+ ENV HUGGINGFACE_API_TOKEN=default_huggingface_token
21
+
22
+ # Set environment variables for Matplotlib and Fontconfig
23
+ ENV MPLCONFIGDIR=/app/matplotlib_cache
24
+ ENV FONTCONFIG_PATH=/app/fontconfig
25
+
26
+ # Create the directories for Matplotlib cache and Fontconfig
27
+ RUN mkdir -p /app/matplotlib_cache /app/fontconfig && \
28
+ chmod -R 777 /app/matplotlib_cache /app/fontconfig
29
+
30
+ # Create a writable directory for Fontconfig cache
31
+ RUN mkdir -p /app/fontconfig_cache && chmod -R 777 /app/fontconfig_cache
32
+
33
+ # Set the environment variable so Fontconfig uses the writable directory
34
+ ENV FONTCONFIG_PATH=/app/fontconfig_cache
35
+
36
+ # Copy the requirements file and install dependencies
37
+ COPY ./requirements.txt /code/requirements.txt
38
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
39
+
40
+ # Copy your application source code and script
41
+ COPY ./api /app
42
+
43
+ CMD ["uvicorn", "app.app.main:app", "--host", "0.0.0.0", "--port", "7860"]