bromite-buildtools/images/github-runner/Dockerfile

114 lines
4.5 KiB
Docker
Raw Normal View History

2021-07-07 15:32:41 +05:30
#FROM nestybox/ubuntu-focal-systemd-docker
2021-07-11 15:02:11 +05:30
FROM ubuntu:20.04
2021-07-07 15:32:41 +05:30
2021-07-13 18:29:40 +05:30
RUN dpkg --add-architecture i386
2021-07-07 15:32:41 +05:30
RUN set -xe && \
echo '#!/bin/sh' > /usr/sbin/policy-rc.d && \
echo 'exit 101' >> /usr/sbin/policy-rc.d && \
chmod +x /usr/sbin/policy-rc.d && \
dpkg-divert --local --rename --add /sbin/initctl && \
cp -a /usr/sbin/policy-rc.d /sbin/initctl && \
sed -i 's/^exit.*/exit 0/' /sbin/initctl && \
echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup && \
echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean && \
echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean && \
echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean && \
echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages && \
echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes && \
echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests
RUN mkdir -p /run/systemd && echo 'docker' > /run/systemd/container
RUN apt-get update && \
apt-get install -y --no-install-recommends \
systemd systemd-sysv libsystemd0 ca-certificates dbus \
iptables iproute2 kmod locales sudo udev && \
echo "ReadKMsg=no" >> /etc/systemd/journald.conf && \
apt-get clean -y && \
rm -rf /var/cache/debconf/* /var/lib/apt/lists/* /var/log/* /tmp/* /var/tmp/* \
/usr/share/doc/* /usr/share/man/* /usr/share/local/* && \
useradd --create-home --shell /bin/bash admin && \
echo "admin:admin" | chpasswd && \
adduser admin sudo
STOPSIGNAL SIGRTMIN+3
RUN apt-get update && \
apt-get install --no-install-recommends -y apt-transport-https ca-certificates \
curl gnupg-agent software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
apt-key fingerprint 0EBFCD88 && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
apt-get update && apt-get install --no-install-recommends -y docker-ce docker-ce-cli containerd.io=1.4.4-1 && \
apt-get clean -y && \
rm -rf /var/cache/debconf/* /var/lib/apt/lists/* /var/log/* /tmp/* /var/tmp/* \
/usr/share/doc/* /usr/share/man/* /usr/share/local/* && \
usermod -a -G docker admin
RUN apt-get update && apt-get install --no-install-recommends -y openssh-server && \
mkdir /home/admin/.ssh && \
chown admin:admin /home/admin/.ssh
EXPOSE 22
2021-07-05 21:18:55 +05:30
# Extra deps for GHA Runner
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
curl \
jq \
sudo \
unzip \
wget \
zip \
git \
2021-07-11 17:04:48 +05:30
pigz \
2021-07-05 21:18:55 +05:30
&& rm -rf /var/lib/apt/list/*
# Add and config runner user as sudo
2021-07-07 15:32:41 +05:30
# Remove default admin user
# https://github.com/nestybox/dockerfiles/blob/master/ubuntu-focal-systemd/Dockerfile
2021-07-05 21:18:55 +05:30
RUN useradd -m runner \
&& usermod -aG sudo runner \
&& usermod -aG docker runner \
2021-07-07 15:32:41 +05:30
&& echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
&& userdel -r admin
2021-07-05 21:18:55 +05:30
# Build args
2021-07-07 15:32:41 +05:30
ARG TARGETPLATFORM=amd64
2021-07-28 01:38:47 +05:30
ARG RUNNER_VERSION=2.302.1
2021-07-05 21:18:55 +05:30
WORKDIR /runner
# Runner download supports amd64 as x64
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \
&& curl -Ls -o runner.tar.gz https://github.com/uazo/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \
&& tar xzf ./runner.tar.gz \
&& rm runner.tar.gz \
&& ./bin/installdependencies.sh \
&& rm -rf /var/lib/apt/lists/*
# Dumb Init
2021-07-07 15:32:41 +05:30
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -Ls -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_${ARCH} \
&& chmod +x /usr/local/bin/dumb-init
#AWS client
#RUN curl -Ls "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip \
# && unzip awscliv2.zip \
# && ./aws/install \
# && rm -rf awscliv2.zip
2021-07-05 21:18:55 +05:30
2021-07-07 15:32:41 +05:30
COPY startup.sh /usr/local/bin/
2021-07-05 21:18:55 +05:30
# Add patched scripts from GHA runner (svc.sh and RunnerService.js)
COPY --chown=runner:runner patched/ ./patched/
2021-07-07 15:32:41 +05:30
RUN chmod +x ./patched/runsvc.sh /usr/local/bin/startup.sh
2021-07-05 21:18:55 +05:30
USER runner
2021-07-07 15:32:41 +05:30
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD ["startup.sh"]