Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +39 -14
Dockerfile
CHANGED
@@ -1,20 +1,45 @@
|
|
1 |
-
# Use
|
2 |
-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
9 |
|
10 |
-
#
|
11 |
-
RUN
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
18 |
|
19 |
-
#
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"]
|