MarkChenX commited on
Commit
cbdad64
·
verified ·
1 Parent(s): a094af9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -14
Dockerfile CHANGED
@@ -1,20 +1,45 @@
1
- # Use an official fastapi runtime as a parent image
2
- FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
 
 
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
6
 
7
- # Copy the current directory contents into the container at /app
8
- COPY . /app
 
9
 
10
- # Give permissions to the script to work directory
11
- RUN chmod +xwr /app
 
12
 
13
- # Install any needed packages specified in requirements.txt
14
- RUN pip install --trusted-host pypi.python.org -r requirements.txt
 
 
 
 
15
 
16
- # Make port 80 available to the world outside this container
17
- EXPOSE 80
 
18
 
19
- # Run index.py when the container launches
20
- CMD ["uvicorn", "app.index:app", "--port", "80", "--reload"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the custom FastAPI image
2
+ # FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
3
+ # Use ubuntu as base image
4
+ FROM ubuntu:20.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 SUPABASE_URL=default_url
19
+ ENV SUPABASE_KEY=default_key
20
+ ENV OPENAI_ORG_ID=default_org_id
21
+ ENV OPENAI_API_KEY=default_api_key
22
+ ENV HUGGINGFACE_API_TOKEN=default_huggingface_token
23
 
24
+ # Set environment variables for Matplotlib and Fontconfig
25
+ ENV MPLCONFIGDIR=/app/matplotlib_cache
26
+ ENV FONTCONFIG_PATH=/app/fontconfig
27
 
28
+ # Create the directories for Matplotlib cache and Fontconfig
29
+ RUN mkdir -p /app/matplotlib_cache /app/fontconfig && \
30
+ chmod -R 777 /app/matplotlib_cache /app/fontconfig
31
+
32
+ # Create a writable directory for Fontconfig cache
33
+ RUN mkdir -p /app/fontconfig_cache && chmod -R 777 /app/fontconfig_cache
34
+
35
+ # Set the environment variable so Fontconfig uses the writable directory
36
+ ENV FONTCONFIG_PATH=/app/fontconfig_cache
37
+
38
+ # Copy the requirements file and install dependencies
39
+ COPY ./requirements.txt /code/requirements.txt
40
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
41
+
42
+ # Copy your application source code and script
43
+ COPY ./api /app
44
+
45
+ CMD ["uvicorn", "app.index:app", "--host", "0.0.0.0", "--port", "7860"]