Skip to content

Commit

Permalink
ci: improve Dockerfile to make proper use of build cache
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Lilljedahl <[email protected]>
  • Loading branch information
marcosnils committed Jun 28, 2024
1 parent ea5023a commit 9d6a681
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i -E 's/^(USERGROUPS_ENAB\s+)yes$/\1no/' /etc/login.defs \
&& localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& useradd --create-home --shell /bin/bash --user-group linuxbrew \
&& useradd -u 1001 --create-home --shell /bin/bash --user-group linuxbrew \
&& echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers \
&& su - linuxbrew -c 'mkdir ~/.linuxbrew'

Expand All @@ -58,10 +58,20 @@ ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}
XDG_CACHE_HOME=/home/linuxbrew/.cache
WORKDIR /home/linuxbrew

RUN mkdir -p \

RUN --mount=type=cache,target=/tmp/homebrew-core,uid=1001,sharing=locked \
# Clone the homebre-core repo into /tmp/homebrew-core or pull latest changes if it exists
git clone https://github.com/homebrew/homebrew-core /tmp/homebrew-core || { cd /tmp/homebrew-core && git pull; } \
&& mkdir -p /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core \
&& cp -r /tmp/homebrew-core /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/


RUN --mount=type=cache,target=/home/linuxbrew/.cache,uid=1001 \
--mount=type=cache,target=/home/linuxbrew/.bundle,uid=1001 \
mkdir -p \
.linuxbrew/bin \
.linuxbrew/etc \
.linuxbrew/include \
.linuxbrew/etc \
.linuxbrew/lib \
.linuxbrew/opt \
.linuxbrew/sbin \
Expand All @@ -76,5 +86,4 @@ RUN mkdir -p \
&& brew cleanup \
&& { git -C .linuxbrew/Homebrew config --unset gc.auto; true; } \
&& { git -C .linuxbrew/Homebrew config --unset homebrew.devcmdrun; true; } \
&& rm -rf .cache \
&& touch .linuxbrew/.homebrewdocker

0 comments on commit 9d6a681

Please sign in to comment.