Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit e7668f7

Browse files
author
Lukas Holzer
authored
chore: make build-image arm64 compatible (#818)
* chore: make build-image arm64 compatible * chore: update * working on arm64 🥳 🍾 * use buildkit for building * retry * retry with environment variable * update ci * cleanup image for linting 🧹 * use hadolint instead of dockerlint * update hadolint job * ignore some warnings in hadolint * last hadolint issue 🧹 * add cross compile platform flag for arm and linux in ci * use buildx manually * update buildx create * fix tags * chore: make ci passing * set BUILDKIT to 1 inside github action as well
1 parent 4d75e7b commit e7668f7

File tree

4 files changed

+92
-67
lines changed

4 files changed

+92
-67
lines changed

.circleci/config.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ jobs:
131131
machine:
132132
image: ubuntu-2004:202111-02
133133
docker_layer_caching: true
134+
environment:
135+
DOCKER_BUILDKIT: 1
134136
resource_class: xlarge
135137
steps:
136138
- checkout
@@ -251,13 +253,6 @@ jobs:
251253
image: << parameters.container-image >>
252254
tag: "${IMAGE_TAG_LIST}"
253255

254-
# Lint our Dockerfile
255-
lint:
256-
executor: docker/machine
257-
steps:
258-
- checkout
259-
- docker/dockerlint
260-
261256
# Workflows are where we specify the job order and job parameters (if applicable)
262257
workflows:
263258
# Workflow responsible for building git tags (commonly the final releases we use within buildbot)
@@ -292,7 +287,8 @@ workflows:
292287
# Workflow responsible for building, pushing and testing branches and PR forks
293288
build-test-and-push:
294289
jobs:
295-
- lint
290+
- docker/hadolint:
291+
ignore-rules: "DL3003,DL3008,DL4001,DL4006"
296292
# Only push images directly if building from a trusted source
297293
# (i.e. not a forked repo)
298294
- build-and-push-images:
@@ -325,10 +321,12 @@ workflows:
325321
requires: [hold-push-to-registry]
326322
- run-tests:
327323
container-image: "netlify/build"
328-
requires: [build-and-push-images, build-images-for-forks, lint]
324+
requires:
325+
[build-and-push-images, build-images-for-forks, docker/hadolint]
329326
- container-structure-tests:
330327
container-image: "netlify/build"
331-
requires: [build-and-push-images, build-images-for-forks, lint]
328+
requires:
329+
[build-and-push-images, build-images-for-forks, docker/hadolint]
332330
# A scheduled daily build and test run to detect issues early instead of during a release or fix
333331
daily-test:
334332
triggers: # Use the triggers key to indicate a scheduled build

.github/workflows/whalescale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
continue-on-error: true
1414
# Build the current commit in order to run the size checks
1515
- name: Build Docker image
16+
env:
17+
DOCKER_BUILDKIT: 1
1618
run: docker build . --build-arg NF_IMAGE_VERSION=$GITHUB_SHA --target build-image -t netlify/build:$GITHUB_SHA
1719
# Compare the new size of the docker image
1820
- name: Check new image size

Dockerfile

Lines changed: 77 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
FROM ubuntu:20.04 as build-image
2-
ARG TARGETARCH=amd64
1+
FROM --platform=$BUILDPLATFORM ubuntu:20.04 as build-image
2+
3+
ARG TARGETARCH
34
ENV TARGETARCH "${TARGETARCH}"
5+
# The semver version associated with this build (i.e. v3.0.0)
6+
ARG NF_IMAGE_VERSION
7+
ENV NF_IMAGE_VERSION "${NF_IMAGE_VERSION:-latest}"
8+
# The commit SHA tag associated with this build
9+
ARG NF_IMAGE_TAG
10+
ENV NF_IMAGE_TAG "${NF_IMAGE_TAG:-latest}"
11+
# The codename associated with this build (i.e. focal)
12+
ARG NF_IMAGE_NAME
13+
ENV NF_IMAGE_NAME "${NF_IMAGE_NAME:-focal}"
14+
15+
ENV LANGUAGE en_US:en
16+
ENV LANG en_US.UTF-8
17+
ENV LC_ALL en_US.UTF-8
18+
ENV PANDOC_VERSION 2.13
419

520
LABEL maintainer Netlify
621

@@ -10,11 +25,6 @@ LABEL maintainer Netlify
1025
#
1126
################################################################################
1227

13-
ENV LANGUAGE en_US:en
14-
ENV LANG en_US.UTF-8
15-
ENV LC_ALL en_US.UTF-8
16-
ENV PANDOC_VERSION 2.13
17-
1828
# language export needed for ondrej/php PPA https://github.com/oerdnj/deb.sury.org/issues/56
1929
RUN export DEBIAN_FRONTEND=noninteractive && \
2030
apt-get -y update && \
@@ -194,17 +204,27 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
194204
#
195205
################################################################################
196206

197-
RUN wget -nv https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_$TARGETARCH.deb && \
207+
RUN wget -nv --quiet https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_$TARGETARCH.deb && \
198208
dpkg -i wkhtmltox_0.12.6-1.focal_$TARGETARCH.deb && \
199209
rm wkhtmltox_0.12.6-1.focal_$TARGETARCH.deb && \
200-
wkhtmltopdf -V
201-
202-
# install Pandoc (more recent version to what is provided in Ubuntu 14.04)
203-
RUN wget https://github.com/jgm/pandoc/releases/download/$PANDOC_VERSION/pandoc-$PANDOC_VERSION-1-$TARGETARCH.deb && \
210+
wkhtmltopdf -V && \
211+
# install Pandoc (more recent version to what is provided in Ubuntu 14.04)
212+
wget --quiet https://github.com/jgm/pandoc/releases/download/$PANDOC_VERSION/pandoc-$PANDOC_VERSION-1-$TARGETARCH.deb && \
204213
dpkg -i pandoc-$PANDOC_VERSION-1-$TARGETARCH.deb && \
205214
rm pandoc-$PANDOC_VERSION-1-$TARGETARCH.deb && \
206215
pandoc -v
207216

217+
218+
################################################################################
219+
#
220+
# Elm compiler
221+
#
222+
################################################################################
223+
RUN curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz \
224+
&& gunzip elm.gz \
225+
&& chmod +x elm \
226+
&& mv elm /usr/local/bin/
227+
208228
################################################################################
209229
#
210230
# User
@@ -263,7 +283,7 @@ ENV NETLIFY_NODE_VERSION="16"
263283

264284
RUN /bin/bash -c ". ~/.nvm/nvm.sh && \
265285
nvm install --no-progress $NETLIFY_NODE_VERSION && \
266-
npm install -g grunt-cli bower elm@$ELM_VERSION && \
286+
npm install -g grunt-cli bower && \
267287
bash /usr/local/bin/yarn-installer.sh --version $YARN_VERSION && \
268288
nvm alias default node && nvm cache clear"
269289
ENV PATH "/opt/buildhome/.yarn/bin:$PATH"
@@ -284,13 +304,12 @@ USER buildbot
284304

285305
RUN virtualenv -p python2.7 /opt/buildhome/python2.7 && \
286306
/bin/bash -c 'source /opt/buildhome/python2.7/bin/activate' && \
287-
ln -nfs /opt/buildhome/python2.7 /opt/buildhome/python2.7.18
288-
289-
RUN virtualenv -p python3.8 /opt/buildhome/python3.8 && \
307+
ln -nfs /opt/buildhome/python2.7 /opt/buildhome/python2.7.18 && \
308+
virtualenv -p python3.8 /opt/buildhome/python3.8 && \
290309
/bin/bash -c 'source /opt/buildhome/python3.8/bin/activate' && \
291-
ln -nfs /opt/buildhome/python3.8 /opt/buildhome/python3.8.10
292-
293-
RUN /opt/buildhome/python${PIPENV_RUNTIME}/bin/pip install pipenv
310+
# Python 3.8
311+
ln -nfs /opt/buildhome/python3.8 /opt/buildhome/python3.8.10 && \
312+
/opt/buildhome/python${PIPENV_RUNTIME}/bin/pip install pipenv
294313

295314
USER root
296315

@@ -334,28 +353,26 @@ RUN binrc install gohugoio/hugo ${HUGO_VERSION} -c /opt/buildhome/.binrc | xargs
334353
RUN mkdir /opt/leiningen && cd /opt/leiningen && \
335354
curl -sL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein && \
336355
chmod +x lein && \
337-
ln -s /opt/leiningen/lein /usr/local/bin/lein
338-
339-
RUN mkdir /opt/boot-clj && cd /opt/boot-clj && \
356+
ln -s /opt/leiningen/lein /usr/local/bin/lein && \
357+
mkdir /opt/boot-clj && cd /opt/boot-clj && \
340358
curl -sL https://github.com/boot-clj/boot-bin/releases/download/2.5.2/boot.sh > boot && \
341359
chmod +x boot && \
342-
ln -s /opt/boot-clj/boot /usr/local/bin/boot
343-
344-
RUN curl -sL https://download.clojure.org/install/linux-install-1.10.1.492.sh | bash
360+
ln -s /opt/boot-clj/boot /usr/local/bin/boot && \
361+
curl -sL https://download.clojure.org/install/linux-install-1.10.1.492.sh | bash
345362

346363
USER buildbot
347364

348-
RUN lein
349-
350-
RUN boot -u
365+
RUN lein && \
366+
boot -u
351367

352368
################################################################################
353369
#
354370
# Cask
355371
#
356372
################################################################################
357373
USER buildbot
358-
RUN rm -rf /opt/buildhome/.cask && git clone https://github.com/cask/cask.git /opt/buildhome/.cask
374+
RUN rm -rf /opt/buildhome/.cask && \
375+
git clone https://github.com/cask/cask.git /opt/buildhome/.cask
359376
ENV PATH "$PATH:/opt/buildhome/.cask/bin"
360377

361378
###
@@ -381,14 +398,15 @@ USER root
381398
# set default to 8.0
382399
RUN update-alternatives --set php /usr/bin/php8.0 && \
383400
update-alternatives --set phar /usr/bin/phar8.0 && \
384-
update-alternatives --set phar.phar /usr/bin/phar.phar8.0
385-
386-
RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet && \
401+
update-alternatives --set phar.phar /usr/bin/phar.phar8.0 && \
402+
wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet && \
387403
mv composer.phar /usr/local/bin/composer
388404

389405
USER buildbot
390406

391-
RUN mkdir -p /opt/buildhome/.php && ln -s /usr/bin/php8.0 /opt/buildhome/.php/php
407+
RUN mkdir -p /opt/buildhome/.php && \
408+
ln -s /usr/bin/php8.0 /opt/buildhome/.php/php
409+
392410
ENV PATH "/opt/buildhome/.php:$PATH"
393411

394412
################################################################################
@@ -414,14 +432,19 @@ RUN gimme | bash
414432
# Dotnet Core
415433
#
416434
################################################################################
435+
417436
WORKDIR /tmp
437+
418438
ENV DOTNET_VERSION 6.0
419-
RUN wget https://dot.net/v1/dotnet-install.sh
420-
RUN chmod u+x /tmp/dotnet-install.sh
421-
RUN /tmp/dotnet-install.sh -c ${DOTNET_VERSION}
439+
440+
RUN wget --quiet https://dot.net/v1/dotnet-install.sh && \
441+
chmod u+x /tmp/dotnet-install.sh && \
442+
/tmp/dotnet-install.sh -c ${DOTNET_VERSION}
443+
422444
ENV PATH "$PATH:/opt/buildhome/.dotnet/tools"
423445
ENV PATH "$PATH:/opt/buildhome/.dotnet"
424446
ENV DOTNET_ROOT "/opt/buildhome/.dotnet"
447+
425448
#populate local package cache
426449
RUN dotnet new
427450

@@ -438,20 +461,24 @@ ENV PATH "$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH"
438461
################################################################################
439462
#
440463
# Homebrew
464+
# only available for amd64 images NOT inside arm64
441465
#
442466
################################################################################
467+
443468
USER root
469+
444470
RUN mkdir -p /home/linuxbrew/.linuxbrew && chown -R buildbot /home/linuxbrew/
471+
445472
USER buildbot
446-
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
473+
RUN if [ "$TARGETARCH" = "amd64" ] ; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; fi
474+
447475
ENV HOMEBREW_PREFIX "/home/linuxbrew/.linuxbrew"
448476
ENV PATH "${HOMEBREW_PREFIX}/bin:${PATH}"
449477
ENV HOMEBREW_CELLAR "${HOMEBREW_PREFIX}/Cellar"
450478
ENV HOMEBREW_REPOSITORY "${HOMEBREW_PREFIX}/Homebrew"
451479
ENV HOMEBREW_CACHE "/opt/buildhome/.homebrew-cache"
452-
RUN brew tap homebrew/bundle
453480

454-
WORKDIR /
481+
RUN if [ "$TARGETARCH" = "amd64" ] ; then brew tap homebrew/bundle; fi
455482

456483
################################################################################
457484
#
@@ -461,29 +488,22 @@ WORKDIR /
461488
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
462489
ENV PATH "$PATH:/opt/buildhome/.cargo/bin"
463490

464-
# Cleanup
491+
################################################################################
492+
#
493+
# Cleanup 🧹
494+
#
495+
################################################################################
465496
USER root
466497

467498
# Add buildscript for local testing
468499
RUN mkdir -p /opt/build-bin
469-
ADD run-build-functions.sh /opt/build-bin/run-build-functions.sh
470-
ADD run-build.sh /opt/build-bin/build
471-
ADD buildbot-git-config /root/.gitconfig
500+
COPY run-build-functions.sh /opt/build-bin/run-build-functions.sh
501+
COPY run-build.sh /opt/build-bin/build
502+
COPY buildbot-git-config /root/.gitconfig
472503
RUN rm -r /tmp/*
473504

474505
USER buildbot
475-
# The semver version associated with this build (i.e. v3.0.0)
476-
ARG NF_IMAGE_VERSION
477-
ENV NF_IMAGE_VERSION ${NF_IMAGE_VERSION:-latest}
478-
479-
# The commit SHA tag associated with this build
480-
ARG NF_IMAGE_TAG
481-
ENV NF_IMAGE_TAG ${NF_IMAGE_TAG:-latest}
482-
483-
# The codename associated with this build (i.e. focal)
484-
ARG NF_IMAGE_NAME
485-
ENV NF_IMAGE_NAME ${NF_IMAGE_NAME:-focal}
486-
506+
WORKDIR /
487507

488508
################################################################################
489509
#
@@ -496,15 +516,15 @@ FROM build-image as build-image-test
496516
USER buildbot
497517
SHELL ["/bin/bash", "-c"]
498518

499-
ADD --chown=buildbot:buildbot package.json /opt/buildhome/test-env/package.json
519+
COPY --chown=buildbot:buildbot package.json /opt/buildhome/test-env/package.json
500520

501521
# We need to install with `--legacy-peer-deps` because of:
502522
# https://github.com/bats-core/bats-assert/issues/27
503523
RUN cd /opt/buildhome/test-env && . ~/.nvm/nvm.sh && npm i --legacy-peer-deps &&\
504524
ln -s /opt/build-bin/run-build-functions.sh /opt/buildhome/test-env/run-build-functions.sh &&\
505525
ln -s /opt/build-bin/build /opt/buildhome/test-env/run-build.sh
506526

507-
ADD --chown=buildbot:buildbot tests /opt/buildhome/test-env/tests
527+
COPY --chown=buildbot:buildbot tests /opt/buildhome/test-env/tests
508528
WORKDIR /opt/buildhome/test-env
509529

510530
# Set `bats` as entrypoint

focal.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ fileExistenceTests:
6565
gid: 2500 # buildbot
6666

6767
commandTests:
68+
- name: "Elm compiler"
69+
command: "elm"
70+
args: ["--version"]
71+
expectedOutput: ["0.19.1"]
72+
6873
- name: "zstd compression library"
6974
command: "zstd"
7075
args: ["--version"]

0 commit comments

Comments
 (0)