-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
58 lines (42 loc) · 1.6 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
53
54
55
56
57
58
FROM python:3.13-slim-bookworm AS production
ARG RELEASE=0.0.0+dev
ENV RELEASE=$RELEASE
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
ENV PATH="/code/.venv/bin:$PATH"
# PYTHONUNBUFFERED non empty value force the stdout and stderr streams to be unbuffered.
ENV PYTHONUNBUFFERED=1
# PYTHONDONTWRITEBYTECODE prevents python creating .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
# DJANGO_SETTINGS_MODULE is the settings module to use
ENV DJANGO_SETTINGS_MODULE=website.settings.prod
RUN echo 'export PS1="\[\e[36m\]eduzenshell>\[\e[m\] "' >> /root/.bashrc
RUN apt-get update && \
apt-get install --no-install-recommends -y \
gettext \
curl \
libpq-dev \
postgresql-client \
iputils-ping \
httpie \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /code
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev
ADD pyproject.toml uv.lock /code/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
COPY . /code
RUN python manage.py collectstatic --no-input
RUN python manage.py compilemessages
EXPOSE 80
CMD ["sh", "/code/scripts/gunicorn_start.sh"]
# DEVELOPMENT
FROM production AS development
ENV DJANGO_SETTINGS_MODULE=website.settings.dev
RUN echo 'export PS1="\[\e[36m\]eduzenshell>\[\e[m\] "' >> /root/.bashrc
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --all-extras --all-groups --dev
CMD ["uv", "run", "manage.py", "runserver", "0.0.0.0:80"]