-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (30 loc) · 1005 Bytes
/
Dockerfile
File metadata and controls
37 lines (30 loc) · 1005 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 public.ecr.aws/docker/library/python:3.10-slim AS base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
build-essential \
libc6-dev \
libffi-dev \
python3-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
# Устанавливаем Python-зависимости
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: copy code, collect static, migrate
FROM base AS build
COPY . .
# Создаём папку для STATIC_ROOT
RUN mkdir -p /app/CourseMC/static
RUN python manage.py collectstatic --noinput && \
python manage.py migrate --noinput
# Stage 3: финальный образ
FROM base AS final
WORKDIR /app
COPY --from=build /app /app
ENV PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=CourseMC.settings
EXPOSE 8000
CMD ["gunicorn", "CourseMC.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3"]