Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix docker build OOMing in CI for arm64 builds #14173

Merged
merged 5 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Inspect builder
run: docker buildx inspect

- name: Log in to DockerHub
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -55,3 +55,6 @@ jobs:
tags: "${{ steps.set-tag.outputs.tags }}"
file: "docker/Dockerfile"
platforms: linux/amd64,linux/arm64
build-args:
# arm64 builds OOM otherwise. c.f. https://github.com/rust-lang/cargo/issues/10583
CARGO_NET_GIT_FETCH_WITH_CLI: true
1 change: 1 addition & 0 deletions changelog.d/14173.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix docker build OOMing in CI for arm64 builds.
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ RUN mkdir /rust /cargo

RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable


# arm64 builds consume a lot of memory if `CARGO_NET_GIT_FETCH_WITH_CLI` is not
# set to true, so we expose it as a build-arg.
ARG CARGO_NET_GIT_FETCH_WITH_CLI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do ARGs become environment variables for the directives below them? (otherwise how does this work?!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I believe so!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it doesn't look like it from a quick local test:

[18:09:36] babolivier@Noah:~/Documents/test$ cat Dockerfile 
FROM alpine
ARG TEST
COPY ./test.sh /test.sh
ENTRYPOINT ["/test.sh"]
[18:10:28] babolivier@Noah:~/Documents/test$ cat test.sh 
#!/bin/sh
env
[18:10:40] babolivier@Noah:~/Documents/test$ docker build -t test -f Dockerfile --build-arg=TEST=foo .
Sending build context to Docker daemon  3.072kB
Step 1/4 : FROM alpine
 ---> 9c6f07244728
Step 2/4 : ARG TEST
 ---> Using cache
 ---> 69700947c516
Step 3/4 : COPY ./test.sh /test.sh
 ---> Using cache
 ---> 2bb37955a594
Step 4/4 : ENTRYPOINT ["/test.sh"]
 ---> Using cache
 ---> 120f3318464d
Successfully built 120f3318464d
Successfully tagged test:latest
[18:12:11] babolivier@Noah:~/Documents/test$ docker run test --build-arg=TEST=foo
HOSTNAME=fce46e554943
SHLVL=1
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
[18:12:17] babolivier@Noah:~/Documents/test$ 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nyargh what

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh for gods sake, RUN $TEST would do the right thing, but we actually need an ENV TEST=$TEST I think


# To speed up rebuilds, install all of the dependencies before we copy over
# the whole synapse project, so that this layer in the Docker cache can be
# used while you develop on the source
Expand Down