Vivek0912 commited on
Commit
9113452
·
1 Parent(s): e8865fd

added some code

Browse files
Files changed (1) hide show
  1. .dockerfile +25 -6
.dockerfile CHANGED
@@ -1,17 +1,36 @@
1
  # Use the official Python 3.11.5 image
2
  FROM python:3.11.5
3
 
4
- # Set the working directory
 
 
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy the backend folder into the container
8
  COPY backend /app
9
 
10
  # Install dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Expose the port FastAPI runs on
14
- EXPOSE 7860
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- # Run FastAPI app
17
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Use the official Python 3.11.5 image
2
  FROM python:3.11.5
3
 
4
+ # Expose the application port
5
+ EXPOSE 7860
6
+
7
+ # Environment settings
8
+ ENV PYTHONDONTWRITEBYTECODE=1
9
+ ENV PYTHONUNBUFFERED=1
10
+
11
+ # Set the working directory inside the container
12
  WORKDIR /app
13
 
14
+ # Copy the backend code into the container
15
  COPY backend /app
16
 
17
  # Install dependencies
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
+ # Create a non-root user
21
+ RUN useradd -m -u 1000 user
22
+
23
+ # Create a writable directory for attachments and assign ownership to the non-root user
24
+ USER root
25
+ RUN mkdir -p /data/attachments && chown -R user:user /data/attachments
26
+
27
+ # Ensure correct permissions (optional but recommended)
28
+ RUN chown -R root:root /app
29
+
30
+ # Switch to the non-root user
31
+ USER user
32
+ ENV HOME=/home/user \
33
+ PATH=/home/user/.local/bin:$PATH
34
 
35
+ # Start the FastAPI application
36
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]