-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (56 loc) · 1.97 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (56 loc) · 1.97 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Stage 1: Build Stage
FROM python:3.9.18-slim AS builder
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install build dependencies including PyMuPDF requirements
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libmupdf-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /jobflow-api
# Copy dependency file and install dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install -r requirements.txt --no-cache-dir && \
pip install gunicorn && \
pip install uvicorn # Add explicit uvicorn installation
# Generate Prisma client (Fixed command)
COPY db/ ./db/
COPY prisma/ ./prisma/
RUN pip install prisma && \
prisma generate --schema=prisma/schema.prisma && \
prisma py fetch
# Copy the rest of the application code
COPY . .
# Stage 2: Final Image
FROM python:3.9.18-slim
# Install runtime dependencies for PyMuPDF
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libmupdf-dev \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/jobflow-api \
PATH="/usr/local/bin:$PATH"
# Install required packages for runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /jobflow-api
# Copy only the installed packages and application from the builder stage
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /jobflow-api /jobflow-api
# Copy gunicorn and uvicorn binaries specifically
COPY --from=builder /usr/local/bin/gunicorn /usr/local/bin/
COPY --from=builder /usr/local/bin/uvicorn /usr/local/bin/
# Expose the port your app runs on
EXPOSE 8000
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]