File size: 822 Bytes
9b37324
 
195c226
fe7157e
 
 
 
195c226
 
fe7157e
 
195c226
 
9b37324
 
fe7157e
195c226
9b37324
 
 
 
 
195c226
fe7157e
9b37324
195c226
 
 
9b37324
195c226
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
# 1. Use Python 3.9
FROM python:3.9

# 2. Set up the user FIRST (Security requirement)
RUN useradd -m -u 1000 user

# 3. Set Working Directory
WORKDIR /code

# 4. Copy Requirements & Install
COPY --chown=user ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# 5. COPY EVERYTHING with Ownership Fix
# This tells Docker: "Make 'user' the owner of all these files, not Root"
COPY --chown=user . /code

# 6. FORCE PERMISSIONS (The Fix for Error 13)
# This grants Read/Write access to the folder so SQLite can create lock files
RUN chmod -R 777 /code

# 7. Switch to the non-root user
USER user

# 8. Set Environment Variables
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# 9. Run the App
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]