rastof9 commited on
Commit
f738cde
·
verified ·
1 Parent(s): 4644b84

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -4
Dockerfile CHANGED
@@ -1,13 +1,27 @@
1
  FROM python:3.9-slim
2
 
 
 
 
 
 
 
 
3
  WORKDIR /app
4
- COPY requirements.txt .
5
- RUN pip install -r requirements.txt
6
 
7
- COPY . .
 
 
8
 
9
- ENV FLASK_APP=manage.py
 
 
 
 
10
  ENV FLASK_ENV=production
11
 
 
12
  EXPOSE 5000
 
 
13
  CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "app:create_app()"]
 
1
  FROM python:3.9-slim
2
 
3
+ # Create a non-root user and set permissions
4
+ RUN useradd -m appuser && mkdir -p /app && chown appuser:appuser /app
5
+
6
+ # Switch to the non-root user
7
+ USER appuser
8
+
9
+ # Set the working directory
10
  WORKDIR /app
 
 
11
 
12
+ # Copy requirements and install dependencies
13
+ COPY --chown=appuser:appuser requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Copy the application code
17
+ COPY --chown=appuser:appuser . .
18
+
19
+ # Set environment variables
20
+ ENV FLASK_APP=app.py
21
  ENV FLASK_ENV=production
22
 
23
+ # Expose the port
24
  EXPOSE 5000
25
+
26
+ # Run the application
27
  CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "app:create_app()"]