File size: 1,114 Bytes
07f753d
 
4eeb5bc
69e8f52
 
07f753d
 
d89c043
 
4eeb5bc
5dcac49
 
8593270
5dcac49
 
8593270
 
07f753d
 
4eeb5bc
69e8f52
5dcac49
8593270
778db15
07f753d
 
69e8f52
8593270
 
07f753d
c3b8ebb
48a6d9c
5dcac49
 
95871f8
5dcac49
 
69e8f52
07f753d
 
69e8f52
 
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
# Dockerfile
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9

# Set environment variables to prevent Python from writing pyc files to disk
# and to force unbuffered output (useful for Docker)
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV HF_HOME "app/cache"
ENV TRANSFORMERS_CACHE "app/cache"

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

# Switch to the "user" user
USER user

# Set the working directory in the container
WORKDIR /app

# Upgrade pip to the latest version and install Python dependencies
COPY --chown=user requirements.txt .

#RUN chown -R user:user /app
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy the FastAPI application code and other necessary files into the container
COPY --chown=user:user ./app .
COPY --chown=user:user .env .

RUN ls

### Update permissions for the app
USER root
RUN chmod 777 .
USER user

# Expose port 7860 for the application
EXPOSE 7860

# Command to run the FastAPI application using uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]