-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
46 lines (33 loc) · 1.17 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
ARG PIP_TOOLS_VERSION=7.4.1
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
ARG PIP_ROOT_USER_ACTION=ignore
# build stage:
FROM python:3.12 AS build
ARG PIP_TOOLS_VERSION
ARG PIP_DISABLE_PIP_VERSION_CHECK
ARG PIP_ROOT_USER_ACTION
WORKDIR /app
COPY requirements.in requirements.txt ./
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip --no-cache-dir --no-cache install "pip-tools==$PIP_TOOLS_VERSION"
RUN cp requirements.txt old.requirements.txt \
&& pip-compile --strip-extras --generate-hashes -q -o requirements.txt requirements.in
RUN echo "Repo/Container Requirements Differences:" \
&& (diff requirements.txt old.requirements.txt || true)
RUN pip wheel --no-cache-dir --no-deps --wheel-dir ./wheels -r requirements.txt
# production stage:
FROM python:3.12-slim
ARG PIP_DISABLE_PIP_VERSION_CHECK
ARG PIP_ROOT_USER_ACTION
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV DJANGO_SETTINGS_MODULE="salekcodes.settings"
WORKDIR /app
COPY --from=build /app/wheels /wheels
COPY . .
RUN pip install --no-cache-dir --no-cache /wheels/*
EXPOSE 8000
CMD ["/bin/bash", "entrypoint.sh"]