2022-04-29 04:21:38 +08:00
|
|
|
ARG version=22.04
|
2022-12-13 18:40:41 +08:00
|
|
|
# version is passed through by Docker.
|
2021-09-14 21:23:39 +08:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
FROM ubuntu:"${version}"
|
2020-04-28 13:37:35 +08:00
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
2018-10-24 12:37:15 +08:00
|
|
|
|
2024-07-10 03:29:49 +08:00
|
|
|
# Deterministic UID (first user). Helps with docker build cache
|
|
|
|
ENV USER_ID=1000
|
|
|
|
# Delete the default ubuntu user & group UID=1000 GID=1000 in Ubuntu 23.04+
|
|
|
|
# that conflicts with the linuxbrew user
|
|
|
|
RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu; true
|
2024-06-29 00:47:22 +08:00
|
|
|
|
2022-12-13 18:40:41 +08:00
|
|
|
# We don't want to manually pin versions, happy to use whatever
|
|
|
|
# Ubuntu thinks is best.
|
2020-04-25 21:16:34 +08:00
|
|
|
# hadolint ignore=DL3008
|
2022-12-13 18:40:41 +08:00
|
|
|
|
2024-09-06 22:39:17 +08:00
|
|
|
# `gh` installation taken from https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
|
2022-12-13 18:40:41 +08:00
|
|
|
# /etc/lsb-release is checked inside the container and sets DISTRIB_RELEASE.
|
2023-03-16 01:19:54 +08:00
|
|
|
# We need `[` instead of `[[` because the shell is `/bin/sh`.
|
|
|
|
# shellcheck disable=SC1091,SC2154,SC2292
|
2018-10-24 12:37:15 +08:00
|
|
|
RUN apt-get update \
|
2022-04-25 13:59:51 +08:00
|
|
|
&& apt-get install -y --no-install-recommends software-properties-common gnupg-agent \
|
2020-05-03 21:29:09 +08:00
|
|
|
&& add-apt-repository -y ppa:git-core/ppa \
|
|
|
|
&& apt-get update \
|
2020-04-26 16:55:14 +08:00
|
|
|
&& apt-get install -y --no-install-recommends \
|
2022-12-13 18:40:41 +08:00
|
|
|
acl \
|
|
|
|
bzip2 \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
file \
|
|
|
|
fonts-dejavu-core \
|
|
|
|
g++ \
|
|
|
|
gawk \
|
|
|
|
git \
|
2023-03-24 16:57:48 +08:00
|
|
|
gpg \
|
2022-12-13 18:40:41 +08:00
|
|
|
less \
|
|
|
|
locales \
|
|
|
|
make \
|
|
|
|
netbase \
|
|
|
|
openssh-client \
|
|
|
|
patch \
|
|
|
|
sudo \
|
2023-03-14 18:53:02 +08:00
|
|
|
unzip \
|
2022-12-13 18:40:41 +08:00
|
|
|
uuid-runtime \
|
|
|
|
tzdata \
|
|
|
|
jq \
|
2023-04-21 17:32:42 +08:00
|
|
|
&& if [ "$(. /etc/lsb-release; echo "${DISTRIB_RELEASE}" | cut -d. -f1)" -ge 22 ]; then apt-get install -y --no-install-recommends skopeo; fi \
|
2024-09-06 22:49:05 +08:00
|
|
|
&& mkdir -p /etc/apt/keyrings \
|
|
|
|
&& chmod 0755 /etc /etc/apt /etc/apt/keyrings \
|
2024-09-06 22:39:17 +08:00
|
|
|
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null \
|
|
|
|
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
|
|
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list >/dev/null \
|
2023-04-21 18:01:08 +08:00
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install -y --no-install-recommends gh \
|
2022-12-01 00:02:46 +08:00
|
|
|
&& apt-get remove --purge -y software-properties-common \
|
|
|
|
&& apt-get autoremove --purge -y \
|
2020-04-28 13:37:35 +08:00
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
2023-11-21 02:54:58 +08:00
|
|
|
&& sed -i -E 's/^(USERGROUPS_ENAB\s+)yes$/\1no/' /etc/login.defs \
|
2020-04-28 13:37:35 +08:00
|
|
|
&& localedef -i en_US -f UTF-8 en_US.UTF-8 \
|
2024-06-29 00:47:22 +08:00
|
|
|
&& useradd -u "${USER_ID}" --create-home --shell /bin/bash --user-group linuxbrew \
|
2021-08-04 07:56:21 +08:00
|
|
|
&& echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers \
|
|
|
|
&& su - linuxbrew -c 'mkdir ~/.linuxbrew'
|
2020-04-28 13:37:35 +08:00
|
|
|
|
2021-08-04 07:56:21 +08:00
|
|
|
USER linuxbrew
|
|
|
|
COPY --chown=linuxbrew:linuxbrew . /home/linuxbrew/.linuxbrew/Homebrew
|
2023-11-21 02:48:37 +08:00
|
|
|
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}" \
|
2023-11-29 23:27:50 +08:00
|
|
|
XDG_CACHE_HOME=/home/linuxbrew/.cache
|
2020-04-28 13:37:35 +08:00
|
|
|
WORKDIR /home/linuxbrew
|
2020-04-25 21:16:34 +08:00
|
|
|
|
2024-06-29 00:47:22 +08:00
|
|
|
|
|
|
|
RUN --mount=type=cache,target=/tmp/homebrew-core,uid="${USER_ID}",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="${USER_ID}" \
|
|
|
|
--mount=type=cache,target=/home/linuxbrew/.bundle,uid="${USER_ID}" \
|
|
|
|
mkdir -p \
|
2022-12-13 18:40:41 +08:00
|
|
|
.linuxbrew/bin \
|
|
|
|
.linuxbrew/etc \
|
|
|
|
.linuxbrew/include \
|
|
|
|
.linuxbrew/lib \
|
|
|
|
.linuxbrew/opt \
|
|
|
|
.linuxbrew/sbin \
|
|
|
|
.linuxbrew/share \
|
|
|
|
.linuxbrew/var/homebrew/linked \
|
|
|
|
.linuxbrew/Cellar \
|
2021-08-18 22:55:05 +08:00
|
|
|
&& ln -s ../Homebrew/bin/brew .linuxbrew/bin/brew \
|
|
|
|
&& git -C .linuxbrew/Homebrew remote set-url origin https://github.com/Homebrew/brew \
|
|
|
|
&& git -C .linuxbrew/Homebrew fetch origin \
|
2023-07-06 02:15:48 +08:00
|
|
|
&& HOMEBREW_NO_ANALYTICS=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap --force homebrew/core \
|
2023-09-05 04:52:51 +08:00
|
|
|
&& brew install-bundler-gems --groups=all \
|
2020-04-28 13:37:35 +08:00
|
|
|
&& brew cleanup \
|
2021-08-18 22:55:05 +08:00
|
|
|
&& { git -C .linuxbrew/Homebrew config --unset gc.auto; true; } \
|
|
|
|
&& { git -C .linuxbrew/Homebrew config --unset homebrew.devcmdrun; true; } \
|
2023-07-07 00:33:49 +08:00
|
|
|
&& touch .linuxbrew/.homebrewdocker
|