File size: 887 Bytes
fa4266d
 
 
0ec8f66
 
 
 
 
 
 
ee01fe1
 
 
b1f9cb5
0ec8f66
6a99b2b
0ec8f66
 
 
f0ed571
 
 
 
 
 
 
0ec8f66
 
fa4266d
f0ed571
 
 
 
 
0ec8f66
5b95557
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
# Use the official Python 3.11.5 image
FROM python:3.11.5

# Expose the application port
EXPOSE 7860

# Environment settings
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Set the working directory inside the container
WORKDIR /app

# Copy the backend code into the container
COPY backend /app

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Create a non-root user
RUN useradd -m -u 1000 user

# Create a writable directory for attachments and assign ownership to the non-root user
USER root
RUN mkdir -p /data/attachments && chown -R user:user /data/attachments

# Ensure correct permissions (optional but recommended)
RUN chown -R root:root /app

# Switch to the non-root user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Start the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]