/
vshmidt
/
label-studio
Обзор
Документация
Войти
/
vshmidt
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
Dockerfile
178 строк
6 KB
Sergey Zhuk
ci: bump poetry to 2.3.2
06 фев 2026, 19:58
06 фев 2026, 19:58
597c0c6
Код
Авторство
О чём код?
# syntax=docker/dockerfile:1 ARG NODE_VERSION=22 ARG PYTHON_VERSION=3.13 ARG POETRY_VERSION=2.3.2 ARG VERSION_OVERRIDE ARG BRANCH_OVERRIDE ################################ Overview # This Dockerfile builds a Label Studio environment. # It consists of five main stages: # 1. "frontend-builder" - Compiles the frontend assets using Node. # 2. "frontend-version-generator" - Generates version files for frontend sources. # 3. "venv-builder" - Prepares the virtualenv environment. # 4. "py-version-generator" - Generates version files for python sources. # 5. "prod" - Creates the final production image with the Label Studio, Nginx, and other dependencies. ################################ Stage: frontend-builder (build frontend assets) FROM --platform=${BUILDPLATFORM} node:${NODE_VERSION}-alpine AS frontend-builder ENV BUILD_NO_SERVER=true \ BUILD_NO_HASH=true \ BUILD_NO_CHUNKS=true \ BUILD_MODULE=true \ YARN_CACHE_FOLDER=/root/web/.yarn \ NX_CACHE_DIRECTORY=/root/web/.nx \ NODE_ENV=production \ NODE_OPTIONS="--max-old-space-size=4096" WORKDIR /label-studio/web RUN apk add --no-cache \ build-base \ pkgconfig \ cairo-dev \ giflib-dev \ libjpeg-turbo-dev \ libpng-dev \ pango-dev \ git \ python3 COPY web/package.json . COPY web/yarn.lock . COPY web/tools tools RUN --mount=type=cache,target=/root/web/.yarn,id=yarn-cache,sharing=locked \ --mount=type=cache,target=/root/web/.nx,id=nx-cache,sharing=locked \ yarn install --prefer-offline --no-progress --pure-lockfile --frozen-lockfile --ignore-engines --non-interactive --production=false COPY web/ . COPY pyproject.toml ../pyproject.toml RUN --mount=type=cache,target=/root/web/.yarn,id=yarn-cache,sharing=locked \ --mount=type=cache,target=/root/web/.nx,id=nx-cache,sharing=locked \ yarn run build ################################ Stage: frontend-version-generator FROM frontend-builder AS frontend-version-generator RUN --mount=type=cache,target=/root/web/.yarn,id=yarn-cache,sharing=locked \ --mount=type=cache,target=/root/web/.nx,id=nx-cache,sharing=locked \ --mount=type=bind,source=.git,target=../.git \ yarn version:libs ################################ Stage: venv-builder (prepare the virtualenv) FROM python:${PYTHON_VERSION}-alpine AS venv-builder ARG POETRY_VERSION ARG PYTHON_VERSION ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=off \ PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DEFAULT_TIMEOUT=100 \ PIP_CACHE_DIR="/.cache" \ POETRY_CACHE_DIR="/.poetry-cache" \ POETRY_HOME="/opt/poetry" \ POETRY_VIRTUALENVS_IN_PROJECT=true \ POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON=true \ PATH="/opt/poetry/bin:$PATH" RUN apk add --no-cache \ build-base \ git \ linux-headers \ python3-dev \ pcre2-dev ADD https://install.python-poetry.org /tmp/install-poetry.py RUN python /tmp/install-poetry.py WORKDIR /label-studio ENV VENV_PATH="/label-studio/.venv" ENV PATH="$VENV_PATH/bin:$PATH" ## Starting from this line all packages will be installed in $VENV_PATH # Copy dependency files COPY pyproject.toml poetry.lock README.md ./ # Set a default build argument for including dev dependencies ARG INCLUDE_DEV=false # Install dependencies RUN --mount=type=cache,target=/.poetry-cache,id=poetry-cache-alpine,sharing=locked \ poetry check --lock && \ if [ "$INCLUDE_DEV" = "true" ]; then \ poetry install --no-root --extras uwsgi --with test; \ else \ poetry install --no-root --without test --extras uwsgi; \ fi # Install LS COPY label_studio label_studio RUN --mount=type=cache,target=/.poetry-cache,id=poetry-cache-alpine,sharing=locked \ # `--extras uwsgi` is mandatory here due to poetry bug: https://github.com/python-poetry/poetry/issues/7302 poetry install --only-root --extras uwsgi && \ python3 label_studio/manage.py collectstatic --no-input ################################ Stage: py-version-generator FROM venv-builder AS py-version-generator ARG VERSION_OVERRIDE ARG BRANCH_OVERRIDE # Create version_.py and ls-version_.py RUN --mount=type=bind,source=.git,target=./.git \ VERSION_OVERRIDE=${VERSION_OVERRIDE} BRANCH_OVERRIDE=${BRANCH_OVERRIDE} poetry run python label_studio/core/version.py ################################### Stage: prod FROM python:${PYTHON_VERSION}-alpine AS production ENV LS_DIR=/label-studio \ HOME=/label-studio \ LABEL_STUDIO_BASE_DATA_DIR=/label-studio/data \ OPT_DIR=/opt/heartex/instance-data/etc \ PATH="/label-studio/.venv/bin:$PATH" \ DJANGO_SETTINGS_MODULE=core.settings.label_studio \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 WORKDIR $LS_DIR # install prerequisites for app RUN apk add --no-cache \ expat \ mesa-gl \ glib \ curl \ nginx \ bash \ procps RUN set -eux; \ mkdir -p $LS_DIR $LABEL_STUDIO_BASE_DATA_DIR $OPT_DIR && \ chown -R 1001:0 $LS_DIR $LABEL_STUDIO_BASE_DATA_DIR $OPT_DIR /var/log/nginx /etc/nginx COPY --chown=1001:0 deploy/default.conf /etc/nginx/nginx.conf # Copy essential files for installing Label Studio and its dependencies COPY --chown=1001:0 pyproject.toml . COPY --chown=1001:0 poetry.lock . COPY --chown=1001:0 README.md . COPY --chown=1001:0 LICENSE LICENSE COPY --chown=1001:0 licenses licenses COPY --chown=1001:0 deploy deploy # Copy files from build stages COPY --chown=1001:0 --from=venv-builder $LS_DIR $LS_DIR COPY --chown=1001:0 --from=py-version-generator $LS_DIR/label_studio/core/version_.py $LS_DIR/label_studio/core/version_.py COPY --chown=1001:0 --from=frontend-builder $LS_DIR/web/dist $LS_DIR/web/dist COPY --chown=1001:0 --from=frontend-version-generator $LS_DIR/web/dist/apps/labelstudio/version.json $LS_DIR/web/dist/apps/labelstudio/version.json COPY --chown=1001:0 --from=frontend-version-generator $LS_DIR/web/dist/libs/editor/version.json $LS_DIR/web/dist/libs/editor/version.json COPY --chown=1001:0 --from=frontend-version-generator $LS_DIR/web/dist/libs/datamanager/version.json $LS_DIR/web/dist/libs/datamanager/version.json USER 1001 EXPOSE 8080 ENTRYPOINT ["./deploy/docker-entrypoint.sh"] CMD ["label-studio"]