Skip to content

Commit 5a7b82d

Browse files
committed
add docker test image
1 parent 17f3111 commit 5a7b82d

File tree

4 files changed

+93
-1
lines changed

4 files changed

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