-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (26 loc) · 755 Bytes
/
Dockerfile
File metadata and controls
37 lines (26 loc) · 755 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
# Stage 1: Install dependencies
FROM python:3.9-alpine AS builder
# Install build dependencies
RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev git
# Set working directory
WORKDIR /app
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Stage 2: Final image
FROM python:3.9-alpine
# Install runtime dependencies
RUN apk add --no-cache git
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set working directory
WORKDIR /app
# Copy installed dependencies from builder
COPY --from=builder /install /usr/local
# Copy application code
COPY . .
# Expose port
EXPOSE 5000
# Run the application
CMD ["python", "app.py"]