-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (32 loc) · 937 Bytes
/
Copy pathDockerfile
File metadata and controls
44 lines (32 loc) · 937 Bytes
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
38
39
40
41
42
43
44
# Stage 1: Build Stage
FROM python:3.11-slim AS builder
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set working directory
WORKDIR /app
# Copy requirements.txt to install dependencies
COPY requirements.txt .
# Install dependencies in a virtual environment
RUN python -m venv /opt/venv \
&& . /opt/venv/bin/activate \
&& pip install --no-cache-dir -r requirements.txt
# Stage 2: Production Stage
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PATH="/opt/venv/bin:$PATH"
ENV DEBUG=0
# Set working directory
WORKDIR /app
# Copy virtual environment from the builder stage
COPY --from=builder /opt/venv /opt/venv
# Copy the rest of the application code
COPY . .
# Expose port 8000
EXPOSE 8000
# Run the start script
ENTRYPOINT [ "./start.sh" ]
# Run the application
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]