-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
51 lines (37 loc) · 1.21 KB
/
Dockerfile
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
45
46
47
48
49
50
51
# Stage 1: Build stage
FROM python:3.9-slim AS builder
# Set environment variables for security and non-interactive installs
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements file
COPY requirements.txt .
# Install python dependencies in a temporary directory
RUN pip install --prefix=/install -r requirements.txt
# Stage 2: Production stage
FROM python:3.9-slim
# Set environment variables for security and non-interactive installs
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system dependencies for runtime only (no build tools)
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the python dependencies from the build stage
COPY --from=builder /install /usr/local
# Set working directory
WORKDIR /app
# Copy project files
COPY . .
ENV PYTHONPATH=/app/src
RUN chmod +x welcome_script.sh
CMD ["./welcome_script.sh"]