Skip to content

Commit 05dfa52

Browse files
authored
Merge pull request opendatahub-io#6 from zdtsw-forking/konflux_build_odh
build: for konflux
2 parents 9bc5be1 + 2d1446d commit 05dfa52

2 files changed

Lines changed: 41 additions & 22 deletions

File tree

services/uds_tokenizer/Dockerfile.konflux

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Build stage use ubi image for konflux
15+
# Build stage
1616
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/python-312:9.7 as builder
1717

1818
# Set build arguments
@@ -21,48 +21,54 @@ ARG TARGETPLATFORM
2121
# Set working directory
2222
WORKDIR /app
2323

24-
# Copy dependencies and install them
24+
# Run as root for build stage
25+
USER root
26+
27+
# use requirments.txt for konflux
2528
COPY requirements.txt /app/requirements.txt
2629
RUN pip install --no-cache-dir -r requirements.txt
2730

2831
# Runtime stage
2932
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/python-312:9.7
3033

34+
# Set build arguments
35+
ARG HEALTH_PORT=8082
36+
3137
# Set working directory
3238
WORKDIR /app
3339

34-
# Need root user to do update
35-
USER root
36-
# microdnf does not exist in base image, only yum
37-
RUN yum update -y && yum clean all && rm -rf /var/cache/yum
38-
39-
# Copy installed dependencies from build stage
40+
# Copy installed dependencies from build stage (UBI uses /opt/app-root/)
4041
COPY --from=builder /opt/app-root/lib/python3.12/site-packages /opt/app-root/lib/python3.12/site-packages
4142
# Copy executables from build stage
4243
COPY --from=builder /opt/app-root/bin/ /opt/app-root/bin/
4344

44-
# Ensure PATH includes /opt/app-root/bin for 3.12
45-
ENV PATH="/opt/app-root/bin:${PATH}"
45+
# Need root for chown operations
46+
USER root
4647

4748
# Copy project files into the image
4849
COPY run_grpc_server.py /app/
4950
COPY tokenizer_grpc_service.py /app/tokenizer_grpc_service.py
50-
COPY models/ /app/models/
51+
COPY tokenizers/ /app/tokenizers/
5152
COPY utils/ /app/utils/
5253
COPY tokenizer_service/ /app/tokenizer_service/
5354
COPY tokenizerpb/ /app/tokenizerpb/
5455

55-
# Create directories and set permissions for non-root user 1001(ubi use this than 65532)
56-
# - /tmp/tokenizer: UDS socket directory
57-
# - /app/models: Model cache directory
58-
# - /.modelscope: ModelScope cache directory
59-
# - /.cache: Hugging Face cache directory
60-
RUN mkdir -p /tmp/tokenizer /app/models /.modelscope /.cache && \
61-
chown -R 1001:0 /tmp/tokenizer /app/models /.modelscope /.cache && \
62-
chmod -R g=u /tmp/tokenizer /app/models /.modelscope /.cache
56+
# Create directory for UDS socket
57+
RUN mkdir -p /tmp/tokenizer && chown 65532:65532 /tmp/tokenizer
58+
59+
# Create tokenizer cache directories and set permissions
60+
ENV TOKENIZERS_DIR=/app/tokenizers
61+
RUN mkdir -p /app/tokenizers && chown -R 65532:65532 /app/tokenizers
62+
# Create and set permissions for ModelScope directory
63+
RUN mkdir -p /.modelscope && chown -R 65532:65532 /.modelscope
64+
# Create and set permissions for Hugging Face cache directory
65+
RUN mkdir -p /.cache && chown -R 65532:65532 /.cache
66+
67+
# Switch to non-root user
68+
USER 65532:65532
6369

64-
# Switch to non-root user (1001 is the default non-root user in UBI images)
65-
USER 1001
70+
# Expose health check port (configurable via build arg)
71+
EXPOSE ${HEALTH_PORT}
6672

6773
# Startup command: run direct gRPC server
68-
CMD ["python3", "/app/run_grpc_server.py"]
74+
CMD ["python", "/app/run_grpc_server.py"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pydantic==2.11.7
2+
shortuuid==1.0.13
3+
transformers==4.53.0
4+
safetensors==0.5.3
5+
Jinja2==3.1.6
6+
modelscope
7+
huggingface-hub
8+
aiohttp==3.9.5
9+
protobuf==6.31.1
10+
tiktoken>=0.7.0
11+
grpcio==1.76.0
12+
grpcio-tools==1.76.0
13+
grpcio-reflection==1.76.0

0 commit comments

Comments
 (0)