Skip to content

Commit e2e8174

Browse files
authored
ci: use maintained Docker images with internal Buildx (#894)
ci: use maintained Docker images with internal Buildx Co-authored-by: eric.lim <eric.lim@datadoghq.com>
1 parent 8b3a875 commit e2e8174

3 files changed

Lines changed: 31 additions & 17 deletions

File tree

‎ci/get_secrets.sh‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ _get_dd_api_key
9393

9494
printf "Assuming role...\n"
9595

96-
export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \
97-
$(aws sts assume-role \
98-
--role-arn "arn:aws:iam::$AWS_ACCOUNT:role/$ROLE_TO_ASSUME" \
96+
AWS_CREDENTIALS=$(aws sts assume-role \
97+
--role-arn "arn:aws:iam::$AWS_ACCOUNT:role/$ROLE_TO_ASSUME" \
9998
--role-session-name "ci.datadog-lambda-python-$CI_JOB_ID-$CI_JOB_STAGE" \
10099
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
101-
--external-id $EXTERNAL_ID \
102-
--output text))
100+
--external-id "$EXTERNAL_ID" \
101+
--output text)
102+
read -r AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN <<< "$AWS_CREDENTIALS"
103+
unset AWS_CREDENTIALS
104+
export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN

‎ci/input_files/build.yaml.tpl‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ default:
1818
# Retry when the runner fails to start
1919
- runner_system_failure
2020

21+
# The Noble Python image uses managed system Python and does not include AWS CLI.
22+
.install-python-tools: &install-python-tools
23+
- apt-get update
24+
- apt-get install -y --no-install-recommends python3-venv python-is-python3
25+
- python3 -m venv /opt/ci-python-tools
26+
- /opt/ci-python-tools/bin/pip install awscli
27+
- export PATH="/opt/ci-python-tools/bin:$PATH"
28+
2129
# This is for serverless framework
2230
.install-node: &install-node
2331
- apt-get update
@@ -42,7 +50,7 @@ default:
4250
build-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
4351
stage: build
4452
tags: ["arch:amd64"]
45-
image: registry.ddbuild.io/images/docker:20.10
53+
image: registry.ddbuild.io/images/docker:27.3.1
4654
artifacts:
4755
expire_in: 1 day # Unsigned zips expire in 1 day
4856
paths:
@@ -57,7 +65,7 @@ build-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
5765
check-layer-size ({{ $runtime.name }}-{{ $runtime.arch }}):
5866
stage: test
5967
tags: ["arch:amd64"]
60-
image: registry.ddbuild.io/images/docker:20.10
68+
image: registry.ddbuild.io/images/docker:27.3.1
6169
needs:
6270
- build-layer ({{ $runtime.name }}-{{ $runtime.arch }})
6371
dependencies:
@@ -103,7 +111,7 @@ unit-test ({{ $runtime.name }}-{{ $runtime.arch }}):
103111
integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
104112
stage: test
105113
tags: ["arch:amd64"]
106-
image: registry.ddbuild.io/images/docker:20.10-py3
114+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
107115
rules:
108116
- if: '$SKIP_E2E_TESTS == "true"'
109117
when: never
@@ -116,19 +124,20 @@ integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
116124
variables:
117125
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
118126
before_script:
127+
- *install-python-tools
119128
- *install-node
120129
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh
121130
- yarn global add serverless@^3.38.0 --prefix /usr/local
122131
- yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local
123-
- cd integration_tests && yarn install && cd ..
132+
- yarn --cwd tests/integration install
124133
script:
125134
- RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh
126135
retry: 2
127136

128137
sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
129138
stage: sign
130139
tags: ["arch:amd64"]
131-
image: registry.ddbuild.io/images/docker:20.10-py3
140+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
132141
rules:
133142
- if: '$CI_COMMIT_TAG =~ /^v.*/'
134143
when: manual
@@ -145,6 +154,7 @@ sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
145154
paths:
146155
- .layers/datadog_lambda_py-{{ $runtime.arch }}-{{ $runtime.python_version }}.zip
147156
before_script:
157+
- *install-python-tools
148158
- apt-get update
149159
- apt-get install -y uuid-runtime
150160
{{ with $environment := (ds "environments").environments.prod }}
@@ -159,7 +169,7 @@ sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}):
159169
publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}):
160170
stage: publish
161171
tags: ["arch:amd64"]
162-
image: registry.ddbuild.io/images/docker:20.10-py3
172+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
163173
rules:
164174
- if: '$SKIP_E2E_TESTS == "true"'
165175
when: never
@@ -194,6 +204,8 @@ publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}):
194204
- {{ .code }}
195205
{{- end}}
196206
before_script:
207+
- *install-python-tools
208+
- export SKIP_PIP_INSTALL=true
197209
- EXTERNAL_ID_NAME={{ $environment.external_id }} ROLE_TO_ASSUME={{ $environment.role_to_assume }} AWS_ACCOUNT={{ $environment.account }} source ./ci/get_secrets.sh
198210
script:
199211
- STAGE={{ $environment_name }} PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} DOTENV={{ $dotenv }} ./ci/publish_layers.sh
@@ -205,8 +217,9 @@ publish-layer-{{ $environment_name }} ({{ $runtime.name }}-{{ $runtime.arch }}):
205217
publish-pypi-package:
206218
stage: publish
207219
tags: ["arch:amd64"]
208-
image: registry.ddbuild.io/images/docker:20.10-py3
220+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
209221
before_script:
222+
- *install-python-tools
210223
- ./scripts/setup_python_env.sh
211224
cache: []
212225
rules:
@@ -221,7 +234,7 @@ publish-pypi-package:
221234
layer bundle:
222235
stage: build
223236
tags: ["arch:amd64"]
224-
image: registry.ddbuild.io/images/docker:20.10
237+
image: registry.ddbuild.io/images/docker:27.3.1
225238
needs:
226239
{{ range $runtimes }}
227240
- build-layer ({{ .name }}-{{ .arch }})
@@ -242,7 +255,7 @@ layer bundle:
242255

243256
signed layer bundle:
244257
stage: sign
245-
image: registry.ddbuild.io/images/docker:20.10-py3
258+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
246259
tags: ["arch:amd64"]
247260
rules:
248261
- if: '$CI_COMMIT_TAG =~ /^v.*/'
@@ -290,7 +303,7 @@ e2e-test:
290303

291304
e2e-test-status:
292305
stage: e2e
293-
image: registry.ddbuild.io/images/docker:20.10-py3
306+
image: registry.ddbuild.io/images/docker:29.4.0-noble-py3
294307
tags: ["arch:amd64"]
295308
timeout: 3h
296309
rules:

‎scripts/setup_python_env.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ if [ -z "${IS_LINT:-}" ] || [ "${IS_LINT}" = "0" ] || [ "${IS_LINT}" = "false" ]
6565
spec_ddtrace_dep
6666
fi
6767

68-
pip install virtualenv
69-
virtualenv venv
68+
python3 -m venv venv
7069
source venv/bin/activate
7170
pip install .[dev]
7271
pip install poetry

0 commit comments

Comments
 (0)