|
| 1 | +# [Node Stage to get node_modolues and node dependencies] |
| 2 | +FROM node:20.11.0-bullseye as node_stage |
| 3 | + |
| 4 | +COPY ./yarn.lock yarn.lock |
| 5 | +COPY ./package.json package.json |
| 6 | + |
| 7 | +RUN corepack enable |
| 8 | +RUN yarn install --immutable |
| 9 | + |
| 10 | +# [Python Stage for Django web server] |
| 11 | +FROM python:3.10.14-slim-bullseye as python_stage |
| 12 | + |
| 13 | +WORKDIR /app |
| 14 | + |
| 15 | +ENV PYTHONUNBUFFERED=1 \ |
| 16 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 17 | + PIP_DISABLE_PIP_VERSION_CHECK=on \ |
| 18 | + PIP_DEFAULT_TIMEOUT=100 \ |
| 19 | + POETRY_HOME="/opt/poetry" \ |
| 20 | + POETRY_VIRTUALENVS_IN_PROJECT=true \ |
| 21 | + POETRY_NO_INTERACTION=1 |
| 22 | + |
| 23 | +# Infrastructure tools |
| 24 | +# gettext is used for django to compile .po to .mo files. |
| 25 | +RUN apt-get update |
| 26 | +RUN apt-get install -y \ |
| 27 | + libpq-dev \ |
| 28 | + gcc \ |
| 29 | + zlib1g-dev \ |
| 30 | + libjpeg62-turbo-dev \ |
| 31 | + mime-support \ |
| 32 | + gettext \ |
| 33 | + libxml2-dev \ |
| 34 | + libxslt-dev |
| 35 | + |
| 36 | +# Install Poetry |
| 37 | +RUN pip install --no-cache-dir pip==23.3.2 && \ |
| 38 | + pip install --no-cache-dir poetry==1.8.2 |
| 39 | + |
| 40 | +# Install Python dependencies |
| 41 | +COPY pyproject.toml poetry.lock ./ |
| 42 | +RUN poetry install --no-root && \ |
| 43 | + yes | poetry cache clear --all pypi |
| 44 | + |
| 45 | +# Add poetry bin directory to PATH |
| 46 | +ENV PATH="${WORKDIR}/.venv/bin:$PATH" |
| 47 | + |
| 48 | +COPY --from=node_stage /node_modules ./node_modules |
| 49 | +COPY --from=node_stage /usr/local/bin/node /usr/local/bin/node |
0 commit comments