Skip to content

Commit 9f81029

Browse files
authored
feat: DEV-2750: Add ubi-based docker image (#2610)
1 parent 12cdfde commit 9f81029

8 files changed

+390
-6
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
!label_studio/**
1111
!setup.py
1212
!README.md
13+
!licenses/**
14+
!LICENSE

.github/workflows/cicd_pipeline.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
docker:
5353
- 'label_studio/**'
5454
- 'deploy/**'
55-
- 'Dockerfile'
55+
- 'Dockerfile**'
5656
- 'setup.py'
5757
5858
pr_labeler:

.github/workflows/docker-build.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
IMAGE_NAME: heartexlabs/label-studio
1313
RELEASE_TAG: 'latest'
1414
DEVELOP_TAG: 'develop'
15+
UBI_TAG: 'ubi_develop'
1516

1617
jobs:
1718
docker_build_and_push:
@@ -47,15 +48,29 @@ jobs:
4748
cat $(pwd)/label_studio/core/version_.py
4849
4950
- name: Download feature flags
51+
env:
52+
LAUNCHDARKLY_COMMUNITY_SDK_KEY: ${{ secrets.LAUNCHDARKLY_COMMUNITY_SDK_KEY }}
5053
run: |
51-
curl -H "Authorization: ${{ secrets.LAUNCHDARKLY_COMMUNITY_SDK_KEY }}" https://app.launchdarkly.com/sdk/latest-all > label_studio/feature_flags.json
54+
curl -H "Authorization: $LAUNCHDARKLY_COMMUNITY_SDK_KEY" https://app.launchdarkly.com/sdk/latest-all > label_studio/feature_flags.json
5255
53-
- name: Build and push
56+
- name: Build and push ubuntu
5457
uses: docker/[email protected]
55-
id: docker_build_and_push
58+
id: docker_build_and_push_ubuntu
5659
with:
5760
context: .
61+
file: Dockerfile
5862
push: true
5963
tags: ${{ env.IMAGE_NAME }}:${{ env.DEVELOP_TAG }}
6064
cache-from: type=gha
6165
cache-to: type=gha,mode=max
66+
67+
- name: Build and push ubi
68+
uses: docker/[email protected]
69+
id: docker_build_and_push_ubi
70+
with:
71+
context: .
72+
file: Dockerfile.redhat
73+
push: true
74+
tags: ${{ env.IMAGE_NAME }}:${{ env.UBI_TAG }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max

.github/workflows/upload_to_pypi.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ jobs:
5959
python label_studio/manage.py collectstatic
6060
6161
- name: Download feature flags
62+
env:
63+
LAUNCHDARKLY_COMMUNITY_SDK_KEY: ${{ secrets.LAUNCHDARKLY_COMMUNITY_SDK_KEY }}
6264
run: |
63-
curl -H "Authorization: ${{ secrets.LAUNCHDARKLY_COMMUNITY_SDK_KEY }}" https://app.launchdarkly.com/sdk/latest-all >label_studio/feature_flags.json
65+
curl -H "Authorization: $LAUNCHDARKLY_COMMUNITY_SDK_KEY" https://app.launchdarkly.com/sdk/latest-all >label_studio/feature_flags.json
6466
6567
- name: Package
6668
run: python setup.py sdist bdist_wheel

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ RUN --mount=type=cache,target=$NPM_CACHE_LOCATION \
1313
npm ci \
1414
&& npm run build:production
1515

16-
1716
FROM ubuntu:20.04
1817

1918
ENV DEBIAN_FRONTEND=noninteractive \

Dockerfile.redhat

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# syntax=docker/dockerfile:1.3
2+
FROM registry.access.redhat.com/ubi8/nodejs-14-minimal AS frontend-builder
3+
4+
ENV NPM_CACHE_LOCATION=$HOME/.npm \
5+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
6+
7+
WORKDIR /label-studio/label_studio/frontend
8+
9+
COPY --chown=1001:0 label_studio/frontend .
10+
COPY --chown=1001:0 label_studio/__init__.py /label-studio/label_studio/__init__.py
11+
12+
RUN --mount=type=cache,target=$NPM_CACHE_LOCATION,uid=1001,gid=0 \
13+
npm ci \
14+
&& npm run build:production
15+
16+
FROM registry.access.redhat.com/ubi8/python-39
17+
18+
ENV LS_DIR=/label-studio \
19+
PIP_CACHE_DIR=$HOME/.cache \
20+
DJANGO_SETTINGS_MODULE=core.settings.label_studio \
21+
LABEL_STUDIO_BASE_DATA_DIR=/label-studio/data
22+
23+
WORKDIR $LS_DIR
24+
25+
# Copy and install middleware dependencies
26+
COPY --chown=1001:0 deploy/requirements-mw.txt .
27+
RUN --mount=type=cache,target=$PIP_CACHE_DIR,uid=1001,gid=0 \
28+
pip3 install -r requirements-mw.txt
29+
30+
# Copy and install requirements.txt first for caching
31+
COPY --chown=1001:0 deploy/requirements.txt .
32+
RUN --mount=type=cache,target=$PIP_CACHE_DIR,uid=1001,gid=0 \
33+
pip3 install -r requirements.txt
34+
35+
COPY --chown=1001:0 . .
36+
RUN --mount=type=cache,target=$PIP_CACHE_DIR,uid=1001,gid=0 \
37+
pip3 install -e .
38+
39+
RUN rm -rf ./label_studio/frontend
40+
COPY --chown=1001:0 --from=frontend-builder /label-studio/label_studio/frontend/dist ./label_studio/frontend/dist
41+
42+
RUN python3 label_studio/manage.py collectstatic --no-input
43+
44+
EXPOSE 8080
45+
46+
LABEL name="LabelStudio" \
47+
maintainer="[email protected]" \
48+
vendor="Heartex" \
49+
version="1.5.0dev" \
50+
release="1" \
51+
summary="LabelStudio" \
52+
description="Label Studio is an open source data labeling tool."
53+
54+
COPY --chown=1001:0 licenses/ /licenses
55+
RUN cp $LS_DIR/LICENSE /licenses
56+
57+
ENTRYPOINT ["./deploy/docker-entrypoint.sh"]
58+
CMD ["label-studio"]

licenses/django_license.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) Django Software Foundation and individual contributors.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
14+
3. Neither the name of Django nor the names of its contributors may be used
15+
to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)