Skip to content

Commit 6d221a2

Browse files
authored
support arm64 / amd64 arch (#1300) (#1463)
1 parent 9f7dfd5 commit 6d221a2

File tree

3 files changed

+52
-32
lines changed

3 files changed

+52
-32
lines changed

docker/Dockerfile

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
1-
FROM node:16.14.0
1+
# use bullseye node base, as debian does provide a chromium for arm64 and amd64 flavour
2+
FROM node:16-bullseye
23

34
ARG BACKSTOPJS_VERSION
5+
ARG DEBIAN_FRONTEND=noninteractive
46

5-
ENV \
6-
BACKSTOPJS_VERSION=$BACKSTOPJS_VERSION
7+
ENV BACKSTOPJS_VERSION=$BACKSTOPJS_VERSION
78

8-
# Base packages
9-
RUN apt-get update && \
10-
apt-get install -y git sudo software-properties-common
9+
# install chromium and its deps
10+
RUN apt-get -qq update >/dev/null && apt-get install -qq fonts-liberation chromium >/dev/null
1111

12-
RUN sudo npm install -g --unsafe-perm=true --allow-root backstopjs@${BACKSTOPJS_VERSION}
13-
14-
RUN wget https://dl-ssl.google.com/linux/linux_signing_key.pub && sudo apt-key add linux_signing_key.pub
15-
RUN sudo add-apt-repository "deb http://dl.google.com/linux/chrome/deb/ stable main"
16-
17-
# RUN apt-get -y update && apt-get -y install google-chrome-stable
18-
19-
# RUN apt-get install -y firefox-esr
20-
21-
# gconf-service libxext6.... added for https://github.com/garris/BackstopJS/issues/1225
22-
23-
RUN apt-get -qqy update \
24-
&& apt-get -qqy --no-install-recommends install \
25-
libfontconfig \
26-
libfreetype6 \
27-
xfonts-cyrillic \
28-
xfonts-scalable \
29-
fonts-liberation \
30-
fonts-ipafont-gothic \
31-
fonts-wqy-zenhei \
32-
libgbm-dev \
33-
gconf-service libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxss1 libxtst6 libappindicator1 libnss3 libasound2 libatk1.0-0 libc6 ca-certificates fonts-liberation lsb-release xdg-utils wget \
34-
&& rm -rf /var/lib/apt/lists/* \
35-
&& apt-get -qyy clean
12+
USER root
13+
# skip download, we already have it installed
14+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
15+
RUN npm install -g --unsafe-perm=true --allow-root backstopjs@${BACKSTOPJS_VERSION}
16+
RUN rm -rf /var/lib/apt/lists/* && apt-get -qq clean >/dev/null
3617

18+
USER node
3719

20+
# set executable path
21+
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
3822
WORKDIR /src
3923

4024
ENTRYPOINT ["backstop"]
25+

docker/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,38 @@ docker run --rm -v $(pwd):/src -it --entrypoint=bash backstopjs/backstopjs
7474

7575
## Jenkins Guide
7676
You could get a Jenkins Guide here: [Jenkins Guide](../examples/Jenkins)
77+
78+
## MultiArch Build
79+
80+
Your docker setup should have buildx support to be able to build that.
81+
82+
```
83+
docker buildx create --name mybuilder --use --bootstrap
84+
```
85+
86+
Build + Push:
87+
88+
```
89+
export BACKSTOPJS_VERSION=6.1.4
90+
docker buildx build --push --build-arg BACKSTOPJS_VERSION --platform linux/amd64,linux/arm64 --tag backstopjs/backstopjs:$BACKSTOPJS_VERSION docker
91+
92+
```
93+
94+
### local load to your registry
95+
96+
build + load it to your registry (load does not support more than 1 platform, push does https://github.com/docker/buildx/issues/59):
97+
98+
AMD64:
99+
100+
```
101+
export BACKSTOPJS_VERSION=6.1.4
102+
docker buildx build --build-arg BACKSTOPJS_VERSION --platform linux/amd64 --load --tag backstopjs/backstopjs:$BACKSTOPJS_VERSION docker
103+
```
104+
105+
ARM64:
106+
107+
```
108+
export BACKSTOPJS_VERSION=6.1.4
109+
docker buildx build --build-arg BACKSTOPJS_VERSION --platform linux/arm64 --load --tag backstopjs/backstopjs:$BACKSTOPJS_VERSION docker
110+
```
111+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"build-and-copy-report-bundle": "npm run build-compare && npm run copy-report-bundle",
3434
"remote": "cd test/configs/ && node ../../cli/index.js remote",
3535
"stop": "cd test/configs/ && node ../../cli/index.js stop",
36-
"build-docker": "PV=$(node -p -e \"require('./package.json').version\"); echo $PV; docker build docker -t backstopjs/backstopjs:$PV --build-arg BACKSTOPJS_VERSION=$PV; docker build docker -t backstopjs/backstopjs:latest --build-arg BACKSTOPJS_VERSION=$PV",
37-
"publish-docker": "PV=$(node -p -e \"require('./package.json').version\"); docker push backstopjs/backstopjs:$PV; docker push backstopjs/backstopjs:latest",
36+
"build-docker": "PV=$(node -p -e \"require('./package.json').version\"); echo $PV; docker buildx build --platform linux/amd64,linux/arm64 -t backstopjs/backstopjs:$PV --build-arg BACKSTOPJS_VERSION=$PV docker; docker buildx build --platform linux/amd64,linux/arm64 -t backstopjs/backstopjs:latest --build-arg BACKSTOPJS_VERSION=$PV docker",
37+
"publish-docker": "PV=$(node -p -e \"require('./package.json').version\"); docker buildx build --push --platform linux/amd64,linux/arm64 -t backstopjs/backstopjs:$PV --build-arg BACKSTOPJS_VERSION=$PV docker; docker buildx build --push --platform linux/amd64,linux/arm64 -t backstopjs/backstopjs:latest --build-arg BACKSTOPJS_VERSION=$PV docker",
3838
"publish-npm": "npm publish",
3939
"build-and-publish": "npm run publish-npm && npm run build-docker && npm run publish-docker"
4040
},

0 commit comments

Comments
 (0)