Skip to content

Commit 14b309d

Browse files
author
Nadia Santalla
authored
Fix: use different chromium versions for different architectures (#1053)
Since we are pinning versions, and since Alpine does not have a consistent set of packages across all the architectures, we have to install different versions of the chromium package depending on which achitecture we are targeting.
1 parent a23d5fa commit 14b309d

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

.github/renovate.json5

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@
7373
{
7474
// Update pinned alpine packages in Dockerfile.
7575
"customType": "regex",
76-
"fileMatch": [ "Dockerfile" ],
76+
"fileMatch": [ "Dockerfile", "Dockerfile.build" ],
7777
"matchStrings": [
78-
// Lines that loosely look like "apk add --repository community something=version".
78+
// Lines that loosely look like "apk add --repository community --arch value something=version".
7979
// To keep this regex simple, only one package per "apk add" is supported.
80-
"\\bapk\\b.+?\\badd\\b.+?(--repository|-X)[ =\\t]+(?<alpineRepo>[a-z]+)\\s+(?<depName>[-\\w]+?)=(?<currentValue>[-.\\w]+)"
80+
"\\bapk\\b.+?\\badd\\b.+?(--repository|-X)[ =\\t]+(?<alpineRepo>[a-z]+)\\s+(--arch[ =\\t]+(?<arch>\\w+)\\s+)?(?<depName>[-\\w]+?)=(?<currentValue>[-.\\w]+)"
8181
],
8282
"versioningTemplate": "loose", // The most lenient versioning renovate supports.
83-
// We use two different datasources for main and community, as alpine serves them in different URLs.
84-
"datasourceTemplate": "custom.alpine-{{alpineRepo}}",
83+
// We use different datasources for main and community, as alpine serves them in different URLs.
84+
// Specifying --arch is optional, if not found it will default to x86_64.
85+
"datasourceTemplate": "custom.alpine-{{alpineRepo}}-{{#if arch}}{{arch}}{{else}}x86_64{{/if}}",
8586
// Extracted "versions" include the package name, so here we strip that prefix using a regex.
8687
"extractVersionTemplate": "{{depName}}-(?<version>.+).apk",
8788
},
@@ -102,13 +103,21 @@
102103
"customDatasources": {
103104
// Use alpine HTML mirror page as a repository. When using `html` format, renovate produces version strings from
104105
// all links present in the page. The version is extracted from that using extractVersionTemplate above.
105-
"alpine-main": {
106+
"alpine-main-x86_64": {
106107
"defaultRegistryUrlTemplate": "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/x86_64/",
107108
"format": "html",
108109
},
109-
"alpine-community": {
110+
"alpine-community-x86_64": {
110111
"defaultRegistryUrlTemplate": "https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/x86_64/",
111112
"format": "html",
112113
},
114+
"alpine-main-aarch64": {
115+
"defaultRegistryUrlTemplate": "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/aarch64/",
116+
"format": "html",
117+
},
118+
"alpine-community-aarch64": {
119+
"defaultRegistryUrlTemplate": "https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/aarch64/",
120+
"format": "html",
121+
},
113122
},
114123
}

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ ENTRYPOINT ["/usr/local/bin/synthetic-monitoring-agent"]
2323
# additionally installs Chromium to support browser checks.
2424
FROM --platform=$TARGETPLATFORM alpine:3.20.3 AS with-browser
2525

26+
ARG TARGETARCH
27+
2628
# Renovate updates the pinned packages below.
2729
# The --repository arg is required for renovate to know which alpine repo it should look for updates in.
2830
# To keep the renovate regex simple, only keep one package installation per line.
29-
RUN apk --no-cache add --repository community tini=0.19.0-r3 && \
30-
apk --no-cache add --repository community chromium-swiftshader=130.0.6723.116-r0
31+
# Furthermore, we split this into two lines to allow for the arm64 and amd64 versions of chromium to be different, as
32+
# they have drifted in the past.
33+
RUN apk --no-cache add --repository community tini=0.19.0-r3
34+
RUN [[ "$TARGETARCH" != "amd64" ]] || apk --no-cache add --repository community --arch x86_64 chromium-swiftshader=131.0.6778.69-r0
35+
RUN [[ "$TARGETARCH" != "arm64" ]] || apk --no-cache add --repository community --arch aarch64 chromium-swiftshader=130.0.6723.116-r0
3136

3237
COPY --from=release /usr/local/bin/synthetic-monitoring-agent /usr/local/bin/synthetic-monitoring-agent
3338
COPY --from=release /usr/local/bin/sm-k6 /usr/local/bin/sm-k6

Dockerfile.build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@ ENTRYPOINT ["/usr/local/bin/synthetic-monitoring-agent"]
2020
# Third stage copies the setup from the base agent and
2121
# additionally installs Chromium to support browser checks.
2222
FROM alpine:3.20.3 AS with-browser
23+
ARG TARGETOS
24+
ARG TARGETARCH
2325

2426
# Renovate updates the pinned packages below.
2527
# The --repository arg is required for renovate to know which alpine repo it should look for updates in.
28+
# The --arch flag is necessary so that it knows which architecture to target.
2629
# To keep the renovate regex simple, only keep one package installation per line.
30+
#
31+
# Alpine does not have a consistent set of packages across all the
32+
# architectures, so we have to install different versions depending on which
33+
# one we are targeting.
2734
RUN apk --no-cache add --repository community tini=0.19.0-r3
28-
RUN apk --no-cache add --repository community chromium-swiftshader=130.0.6723.116-r0
35+
RUN if test "$TARGETARCH" = "amd64" ; then apk --no-cache add --repository community --arch x86_64 chromium-swiftshader=131.0.6778.69-r0 ; fi
36+
RUN if test "$TARGETARCH" = "arm64" ; then apk --no-cache add --repository community --arch aarch64 chromium-swiftshader=130.0.6723.116-r0 ; fi
2937

3038
COPY --from=release /usr/local/bin/synthetic-monitoring-agent /usr/local/bin/synthetic-monitoring-agent
3139
COPY --from=release /usr/local/bin/sm-k6 /usr/local/bin/sm-k6

0 commit comments

Comments
 (0)