Skip to content

Commit 7da9187

Browse files
committed
ddtest
wip
1 parent b17d958 commit 7da9187

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

docker-compose.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ services:
176176
# dockerfile: Dockerfile
177177
image: ghcr.io/datadog/dd-trace-py/testrunner:8b69a2610342b333f8832422ffc4f3a9327bed13@sha256:c2d067947ffdb305fc7dc7ff1f8eb7035cfa110bd1199917dd2519eadd166402
178178
command: bash
179+
entrypoint: /project/scripts/ddtest-entrypoint.sh
179180
environment:
180181
DD_SETUP_CACHE_DOWNLOADS: "1"
181182
DD_CMAKE_INCREMENTAL_BUILD: "1"
@@ -184,11 +185,11 @@ services:
184185
CARGO_BUILD_JOBS: "12"
185186
network_mode: host
186187
userns_mode: host
187-
working_dir: /root/project/
188+
working_dir: /project/
188189
volumes:
189190
- ddagent:/tmp/ddagent
190-
- ./:/root/project
191-
- ./.riot:/root/project/.riot
191+
- ./:/project
192+
- ./.riot:/project/.riot
192193

193194
localstack:
194195
image: localstack/localstack:1.4.0

scripts/ddtest

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ then
99
CMD=bash
1010
fi
1111

12+
# Make UID and GID available to the testrunner container, to run with the same user as the host.
13+
# The entrypoint at scripts/ddtest-entrypoint.sh will drop privileges to the user with the given UID and GID.
14+
# This will ensure any file created on mounted volumes have the right ownership.
15+
export EFFECTIVE_UID=$(id -u)
16+
export EFFECTIVE_GID=$(id -g)
17+
1218
docker compose run \
1319
-e DD_TRACE_AGENT_URL \
20+
-e EFFECTIVE_UID \
21+
-e EFFECTIVE_GID \
1422
--rm \
1523
-i \
1624
testrunner \

scripts/ddtest-entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
# If EFFECTIVE_UID, EFFECTIVE_GID are set, then create a user with that UID and GID
5+
# and drop privileges to that user.
6+
if [ -n "${EFFECTIVE_UID:-}" ] && [ -n "${EFFECTIVE_GID:-}" ]; then
7+
groupadd -g "${EFFECTIVE_GID}" user
8+
useradd -u "${EFFECTIVE_UID}" -g "${EFFECTIVE_GID}" -m user
9+
env
10+
exec su - user -c "$@"
11+
fi
12+
13+
exec "$@"

0 commit comments

Comments
 (0)