Skip to content

Commit

Permalink
ci: PLT-213: Generate frontend version files inside Docker (#5617)
Browse files Browse the repository at this point in the history
Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com>
  • Loading branch information
nikitabelonogov and robot-ci-heartex committed Mar 21, 2024
1 parent 49b5747 commit 3384141
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
!deploy/default.conf
!label_studio/**
label_studio/frontend
!web/**

# FRONTEND
!web
!.git
# Re-ignore node_modules and nx cache
**/node_modules
**/.nx

!README.md
!licenses/**
!LICENSE
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/build_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ on:

env:
PYTHON_VERSION_FILE: "pyproject.toml"
FRONTEND_MONOREPO_DIR: "web"

jobs:
pypi:
Expand Down Expand Up @@ -80,6 +81,21 @@ jobs:
./toml set '${{ env.PYTHON_VERSION_FILE }}' tool.poetry.version "$version" > pyproject.toml.new
mv -f pyproject.toml.new pyproject.toml
- name: Setup frontend environment
uses: ./.github/actions/setup-frontend-environment
with:
node-version: "${{ env.NODE }}"
directory: "${{ env.FRONTEND_MONOREPO_DIR }}"

- name: "Build"
working-directory: "${{ env.FRONTEND_MONOREPO_DIR }}"
run: yarn build

- name: "Generate version files"
continue-on-error: true
working-directory: "${{ env.FRONTEND_MONOREPO_DIR }}"
run: yarn version:libs

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -89,12 +105,10 @@ jobs:
uses: snok/install-poetry@v1

- name: Install Python dependencies
run: |
poetry install --with build
run: poetry install --with build

- name: Collect static
run: |
poetry run python label_studio/manage.py collectstatic
run: poetry run python label_studio/manage.py collectstatic

- name: Download feature flags
env:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ jobs:
node-version: "${{ env.NODE }}"
directory: "${{ env.FRONTEND_MONOREPO_DIR }}"

- name: "Monorepo: Build"
- name: "Build"
working-directory: "${{ env.FRONTEND_MONOREPO_DIR }}"
run: yarn build

- name: Commit and Push
- name: "Generate version files"
continue-on-error: true
working-directory: "${{ env.FRONTEND_MONOREPO_DIR }}"
run: yarn version:libs

- name: "Commit and Push"
run: |
git add "${{ env.FRONTEND_MONOREPO_DIR }}" || true
git status -s
Expand Down
34 changes: 22 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# syntax=docker/dockerfile:1.3
FROM --platform=${BUILDPLATFORM} node:18 AS frontend-builder

ENV NPM_CACHE_LOCATION=$HOME/.cache/yarn/v6 \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
NX_REJECT_UNKNOWN_LOCAL_CACHE=0
# syntax=docker/dockerfile:1
ARG NODE_VERSION=18

################################ Stage: frontend-builder (build frontend assets)
FROM --platform=${BUILDPLATFORM} node:${NODE_VERSION} 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 \
NODE_ENV=production

WORKDIR /label-studio/web

COPY --chown=1001:0 web .
COPY --chown=1001:0 pyproject.toml /label-studio

# Fix Docker Arm64 Build
RUN yarn config set registry https://registry.npmjs.org/
RUN yarn config set network-timeout 1200000 # HTTP timeout used when downloading packages, set to 20 minutes

RUN --mount=type=cache,target=$NPM_CACHE_LOCATION,uid=1001,gid=0 \
yarn install --frozen-lockfile \
&& yarn run build
COPY web/package.json .
COPY web/yarn.lock .
COPY web/tools tools
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},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=${YARN_CACHE_FOLDER},sharing=locked \
--mount=type=bind,source=.git,target=../.git \
yarn run build && yarn version:libs

FROM ubuntu:22.04

Expand Down
2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions web/dist/apps/labelstudio/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"message": "return workaround",
"commit": "2577060e87a20b066d38a575c94d9887a03955a0",
"date": "2024-03-21T17:36:42.000Z",
"branch": "PLT-213"
}
6 changes: 6 additions & 0 deletions web/dist/libs/datamanager/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"message": "return workaround",
"commit": "2577060e87a20b066d38a575c94d9887a03955a0",
"date": "2024-03-21T17:36:42.000Z",
"branch": "PLT-213"
}
6 changes: 6 additions & 0 deletions web/dist/libs/editor/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"message": "return workaround",
"commit": "2577060e87a20b066d38a575c94d9887a03955a0",
"date": "2024-03-21T17:36:42.000Z",
"branch": "PLT-213"
}

0 comments on commit 3384141

Please sign in to comment.