Noel-Teens commited on
Commit
d15be1c
·
1 Parent(s): e4cecb2

Final test

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -9
Dockerfile CHANGED
@@ -1,23 +1,35 @@
1
  FROM python:3.10-slim
2
 
3
- # Create a non-root user (optional but good for security)
4
- RUN useradd -m user
 
 
5
 
6
- # Set working directory
 
 
 
7
  WORKDIR /app
8
 
9
- # Copy requirements and install them
10
- COPY --chown=user requirements.txt .
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy rest of the project files
14
- COPY --chown=user . .
 
 
 
 
 
 
 
15
 
16
  # Switch to non-root user
17
  USER user
18
 
19
- # Expose port
20
  EXPOSE 8000
21
 
22
- # Run the Django server
23
  CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
 
1
  FROM python:3.10-slim
2
 
3
+ # Install system dependencies (SQLite tools & optional debugging)
4
+ RUN apt-get update && apt-get install -y \
5
+ libsqlite3-dev \
6
+ && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Create non-root user
9
+ RUN useradd -ms /bin/bash user
10
+
11
+ # Set workdir
12
  WORKDIR /app
13
 
14
+ # Copy requirements & install as root
15
+ COPY requirements.txt .
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ # Copy project files
19
+ COPY . .
20
+
21
+ RUN python manage.py makemigrations
22
+ RUN python manage.py migrate
23
+
24
+ # Fix permissions: allow user to write to /app and any subdirs
25
+ RUN mkdir -p /app \
26
+ && chown -R user:user /app
27
 
28
  # Switch to non-root user
29
  USER user
30
 
31
+ # Expose Django port
32
  EXPOSE 8000
33
 
34
+ # Run server
35
  CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]