Skip to content

Commit 3d01781

Browse files
✨ Add docker test image for performance tests (ITISFoundation#7053)
1 parent 9c1e764 commit 3d01781

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

tests/performance/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ KERNEL_NAME=$(shell uname -s)
1313

1414
NETWORK_NAME=dashboards_timenet
1515

16+
TEST_IMAGE_NAME := itisfoundation/performance-tests
17+
TEST_IMAGE_TAG := v0
18+
1619
# UTILS
1720
# NOTE: keep short arguments for `cut` so it works in both BusyBox (alpine) AND Ubuntu
1821
get_my_ip := $(shell (hostname --all-ip-addresses || hostname -i) 2>/dev/null | cut -d " " -f 1)
@@ -88,3 +91,11 @@ install-ci:
8891
config: ## Create config for your locust tests
8992
@$(call check_defined, input, please define inputs when calling $@ - e.g. ```make $@ input="--help"```)
9093
@uv run locust_settings.py $(input) | tee "${ENV_FILE}"
94+
95+
96+
.PHONY: build push
97+
build: ## Build test image
98+
docker build -t ${TEST_IMAGE_NAME}:${TEST_IMAGE_TAG} ./docker
99+
100+
push: ## Push test image to dockerhub
101+
docker push ${TEST_IMAGE_NAME}:${TEST_IMAGE_TAG}

tests/performance/docker/Dockerfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG PYTHON_VERSION="3.11.9"
4+
ARG UV_VERSION="0.4"
5+
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv_build
6+
FROM python:${PYTHON_VERSION}-slim-bookworm AS base
7+
8+
LABEL maintainer=bisgaard-itis
9+
10+
# NOTE: to list the latest version run `make` inside `scripts/apt-packages-versions`
11+
ENV DOCKER_APT_VERSION="5:26.1.4-1~debian.12~bookworm"
12+
13+
# -------------------------- Install docker -------------------
14+
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
15+
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
16+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
17+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
18+
set -eux; \
19+
apt-get update; \
20+
apt-get install -y --no-install-recommends \
21+
gosu \
22+
ca-certificates \
23+
curl \
24+
gnupg \
25+
lsb-release \
26+
&& mkdir -p /etc/apt/keyrings \
27+
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
28+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
29+
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
30+
&& apt-get update \
31+
&& apt-get install -y --no-install-recommends \
32+
# only the cli is needed and we remove the unnecessary stuff again
33+
docker-ce-cli=${DOCKER_APT_VERSION} \
34+
&& apt-get remove -y\
35+
gnupg \
36+
curl \
37+
lsb-release \
38+
&& apt-get clean -y\
39+
# verify that the binary works
40+
&& gosu nobody true
41+
42+
# Sets utf-8 encoding for Python et al
43+
ENV LANG=C.UTF-8
44+
45+
# Turns off writing .pyc files; superfluous on an ephemeral container.
46+
ENV PYTHONDONTWRITEBYTECODE=1 \
47+
VIRTUAL_ENV=/home/scu/.venv
48+
49+
# Ensures that the python and pip executables used in the image will be
50+
# those from our virtualenv.
51+
ENV PATH="${VIRTUAL_ENV}/bin:$PATH"
52+
53+
54+
# -------------------------- Build stage -------------------
55+
# Installs build/package management tools and third party dependencies
56+
#
57+
# + /build WORKDIR
58+
#
59+
FROM base AS build
60+
61+
ENV SC_BUILD_TARGET=build
62+
63+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
64+
set -eux \
65+
&& apt-get update \
66+
&& apt-get install -y --no-install-recommends \
67+
build-essential \
68+
curl \
69+
git \
70+
jq
71+
72+
# install UV https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
73+
COPY --from=uv_build /uv /uvx /bin/
74+
75+
RUN uv venv "${VIRTUAL_ENV}"
76+
77+
WORKDIR /test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
locust-plugins
12
parse
23
pydantic
34
pydantic-settings
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
--requirement _base.txt
2-
locust-plugins

0 commit comments

Comments
 (0)