-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
31 lines (24 loc) · 968 Bytes
/
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
# Use multi-stage builds
# Stage 1: Build stage
FROM python:3.11-alpine as builder
WORKDIR /app
COPY requirements.txt .
# Install build dependencies
RUN apk add --no-cache --virtual .build-deps \
build-base python3-dev libpq postgresql-dev gcc jpeg-dev zlib-dev libffi-dev \
&& pip install --no-cache-dir -r requirements.txt \
# Remove build dependencies
&& apk del .build-deps
# Stage 2: Run stage
FROM python:3.11-alpine
WORKDIR /app
# Copy installed python packages from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Install runtime dependencies
RUN apk add --no-cache postgresql-dev jpeg-dev \
&& rm -rf /var/cache/apk/*
COPY . .
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
CMD ["gunicorn", "--reload", "--workers=2", "--worker-tmp-dir", "/dev/shm", "--bind=0.0.0.0:80", "--chdir", "/app/crawler", "crawler.wsgi"]