mirror of https://github.com/locustio/locust.git
32 lines
1.0 KiB
Docker
32 lines
1.0 KiB
Docker
# This is the image pushed to Dockerhub, containing the built and tested Locust package
|
|
|
|
# Stage 1: Install Locust package
|
|
FROM python:3.12-slim AS base
|
|
|
|
FROM base AS builder
|
|
RUN apt-get update && apt-get install -y git
|
|
# there are no wheels for some packages (geventhttpclient?) for arm64/aarch64, so we need some build dependencies there
|
|
RUN if [ -n "$(arch | grep 'arm64\|aarch64')" ]; then apt install -y --no-install-recommends gcc python3-dev; fi
|
|
RUN python -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Install the built Python dist
|
|
COPY ./dist dist
|
|
RUN pip install dist/*.whl
|
|
|
|
# Stage 2: Runtime image
|
|
FROM base
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
# turn off python output buffering
|
|
ENV PYTHONUNBUFFERED=1
|
|
RUN useradd --create-home locust
|
|
# ensure correct permissions
|
|
RUN chown -R locust /opt/venv
|
|
# perform initial bytecode compilation (brings down total startup time from ~0.9s to ~0.6s)
|
|
RUN locust --version
|
|
USER locust
|
|
WORKDIR /home/locust
|
|
EXPOSE 8089 5557
|
|
ENTRYPOINT ["locust"]
|