File size: 1,375 Bytes
9dba887
 
 
3b899cd
 
 
07208d9
 
 
 
 
 
 
bd6255b
 
 
3b899cd
 
 
 
 
 
 
02a5276
7486d9b
21eebbf
02a5276
21eebbf
d83107b
6fc085f
a7e8afe
98b7d12
21eebbf
 
d83107b
6fc085f
02a5276
a7e8afe
98b7d12
21eebbf
02a5276
3b899cd
9dba887
02a5276
3b899cd
 
2bc96b2
02a5276
3b899cd
9dba887
02a5276
7486d9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Use the official Python 3.10.9 image
FROM python:3.10.9

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Install wkhtmltopdf and its dependencies as root
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
    wkhtmltopdf \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/code

# Expose the port FastAPI will run on
EXPOSE 7860

# Set environment variables for FastAPI and OpenAI API keys
ARG FASTAPI_KEY
ARG OPENAI_API_KEY
ARG OPENAI_GENERAL_ASSISTANT
ARG SENTRY_DSN
ARG BING_API_KEY

ENV FASTAPI_KEY=$FASTAPI_KEY
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ENV OPENAI_GENERAL_ASSISTANT=$OPENAI_GENERAL_ASSISTANT
ENV PYTHONUNBUFFERED=1
ENV SENTRY_DSN=$SENTRY_DSN
ENV BING_API_KEY=$BING_API_KEY

# Set the working directory
# WORKDIR /code

# Copy requirements and install dependencies
COPY ./app/requirements.txt $HOME/code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r $HOME/code/requirements.txt

# Copy the app directory
COPY ./app $HOME/code/app

# Start the FastAPI app on port 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "900"]