Skip to content

Commit 07a3db3

Browse files
committed
Rewrite Containerfile as multi-stage build
1 parent 50f6518 commit 07a3db3

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

build/Containerfile

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
1-
FROM python:3.12-slim
1+
ARG PYTHON=3.13
22

3-
LABEL org.opencontainers.image.source="https://github.com/neuralmagic/guidellm"
4-
LABEL org.opencontainers.image.description="GuideLLM Benchmark Container"
3+
# Use a multi-stage build to create a lightweight production image
4+
FROM docker.io/python:${PYTHON}-slim as builder
55

6-
# Install dependencies and set up environment in a single layer
7-
RUN apt-get update && apt-get install -y \
8-
git \
9-
curl \
10-
&& pip install git+https://github.com/neuralmagic/guidellm.git \
11-
&& useradd -m -u 1000 guidellm \
12-
&& apt-get clean \
13-
&& rm -rf /var/lib/apt/lists/*
6+
# Copy repository files
7+
COPY / /src
148

15-
# Set working directory
16-
WORKDIR /app
9+
# Create a venv and install guidellm
10+
RUN python3 -m venv /opt/guidellm \
11+
&& /opt/guidellm/bin/pip install --no-cache-dir /src
12+
13+
# Copy entrypoint script into the venv bin directory
14+
RUN install -m0755 /src/build/entrypoint.sh /opt/guidellm/bin/entrypoint.sh
15+
16+
# Prod image
17+
FROM docker.io/python:${PYTHON}-slim
1718

18-
# Copy and set up the benchmark script
19-
COPY build/run_benchmark.sh /app/
19+
# Copy the virtual environment from the builder stage
20+
COPY --from=builder /opt/guidellm /opt/guidellm
2021

21-
# Set ownership to non-root user
22-
RUN chown -R guidellm:guidellm /app
22+
# Add guidellm bin to PATH
23+
ENV PATH="/opt/guidellm/bin:$PATH"
24+
25+
# Create a non-root user
26+
RUN useradd -md /results guidellm
2327

2428
# Switch to non-root user
2529
USER guidellm
2630

27-
# Healthcheck
28-
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
29-
CMD curl -f http://localhost:8000/health || exit 1
31+
# Set working directory
32+
WORKDIR /results
33+
34+
# Metadata
35+
LABEL org.opencontainers.image.source="https://github.com/neuralmagic/guidellm"
36+
LABEL org.opencontainers.image.description="GuideLLM Benchmark Container"
3037

31-
# Set the entrypoint
32-
ENTRYPOINT ["/app/run_benchmark.sh"]
38+
# Set the environment variable for the benchmark script
39+
# TODO: Replace with scenario environment variables
40+
ENV TARGET="http://localhost:8000" \
41+
MODEL="neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16" \
42+
RATE_TYPE="sweep" \
43+
DATA="prompt_tokens=256,output_tokens=128" \
44+
MAX_REQUESTS="100" \
45+
MAX_SECONDS="" \
46+
OUTPUT_PATH="/results/results.json"
47+
48+
ENTRYPOINT [ "/opt/guidellm/bin/entrypoint.sh" ]

0 commit comments

Comments
 (0)