-
Notifications
You must be signed in to change notification settings - Fork 103
/
Dockerfile
52 lines (37 loc) · 1.26 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
52
FROM python:3.11-alpine as builder
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
POETRY_VERSION=1.2.2 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
PATH="$PATH:/root/.local/bin"
RUN apk add --no-cache \
gcc \
musl-dev \
postgresql-dev \
libffi-dev \
openssl-dev \
cargo \
curl \
gettext \
git
RUN curl -sSL https://install.python-poetry.org | python3 - && poetry --version
WORKDIR /usr/local/src/hexlet-friends
COPY . .
RUN poetry install --extras psycopg2-binary --only main
FROM python:3.11-alpine as runner
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
RUN apk add --no-cache libpq gettext
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY --from=builder /usr/local/src/hexlet-friends /usr/local/src/hexlet-friends
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
RUN chown -R appuser:appgroup /usr/local/src/hexlet-friends
USER appuser
WORKDIR /usr/local/src/hexlet-friends
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]