|
| 1 | +# Note: Using 'docker compose up' will leave you hanging, you need |
| 2 | +# to use 'docker compose run guix_ubuntu' to drop into an |
| 3 | +# interactive shell |
| 4 | + |
| 5 | +FROM ubuntu:focal |
| 6 | + |
| 7 | +SHELL ["/bin/bash", "-c"] |
| 8 | + |
| 9 | +RUN apt-get update && \ |
| 10 | + apt-get install -y --no-install-recommends --no-upgrade \ |
| 11 | + build-essential \ |
| 12 | + bzip2 \ |
| 13 | + ca-certificates \ |
| 14 | + curl \ |
| 15 | + git \ |
| 16 | + locales \ |
| 17 | + netbase \ |
| 18 | + sudo \ |
| 19 | + wget \ |
| 20 | + xz-utils && \ |
| 21 | + rm -rf /var/lib/apt/lists/* |
| 22 | + |
| 23 | +ARG guix_download_path=ftp://ftp.gnu.org/gnu/guix |
| 24 | +ARG guix_version=1.4.0 |
| 25 | +ARG guix_checksum_aarch64=72d807392889919940b7ec9632c45a259555e6b0942ea7bfd131101e08ebfcf4 |
| 26 | +ARG guix_checksum_x86_64=236ca7c9c5958b1f396c2924fcc5bc9d6fdebcb1b4cf3c7c6d46d4bf660ed9c9 |
| 27 | +ARG builder_count=32 |
| 28 | + |
| 29 | +ENV PATH /usr/local/bin:/usr/local/guix/current/bin:$PATH |
| 30 | + |
| 31 | +# Application Setup |
| 32 | +# https://guix.gnu.org/manual/en/html_node/Application-Setup.html |
| 33 | +ENV GUIX_LOCPATH="/usr/local/guix/profile" \ |
| 34 | + LC_ALL="C" |
| 35 | + |
| 36 | +RUN guix_file_name=guix-binary-${guix_version}.$(uname -m)-linux.tar.xz && \ |
| 37 | + eval "guix_checksum=\${guix_checksum_$(uname -m)}" && \ |
| 38 | + cd /tmp && \ |
| 39 | + wget -q -O "$guix_file_name" "${guix_download_path}/${guix_file_name}" && \ |
| 40 | + echo "${guix_checksum} ${guix_file_name}" | sha256sum -c && \ |
| 41 | + tar xJf "$guix_file_name" && \ |
| 42 | + mv var/guix /var/ && \ |
| 43 | + mv gnu / && \ |
| 44 | + mkdir -p /usr/local/guix && \ |
| 45 | + ln -sf /var/guix/profiles/per-user/root/current-guix /usr/local/guix/current && \ |
| 46 | + ln -sf /var/guix/profiles/per-user/root/guix-profile /usr/local/guix/profile && \ |
| 47 | + chmod 1777 /tmp /var/tmp && \ |
| 48 | + source /usr/local/guix/current/etc/profile |
| 49 | + |
| 50 | +RUN touch /etc/nsswitch.conf |
| 51 | + |
| 52 | +RUN guix archive --authorize < /usr/local/guix/current/share/guix/ci.guix.gnu.org.pub && \ |
| 53 | + guix archive --authorize < /usr/local/guix/current/share/guix/bordeaux.guix.gnu.org.pub |
| 54 | + |
| 55 | +# Build Environment Setup |
| 56 | +# https://guix.gnu.org/manual/en/html_node/Build-Environment-Setup.html |
| 57 | +RUN groupadd --system guixbuild && \ |
| 58 | + for i in $(seq -w 1 ${builder_count}); do \ |
| 59 | + useradd -g guixbuild -G guixbuild \ |
| 60 | + -d /var/empty -s $(which nologin) \ |
| 61 | + -c "Guix build user ${i}" --system \ |
| 62 | + "guixbuilder${i}" ; \ |
| 63 | + done |
| 64 | + |
| 65 | +# Create unprivileged user |
| 66 | +ARG USER_ID=1000 \ |
| 67 | + GROUP_ID=1000 \ |
| 68 | + USERNAME=ubuntu |
| 69 | +RUN groupadd -g ${GROUP_ID} ${USERNAME} && \ |
| 70 | + useradd -u ${USER_ID} -g ${USERNAME} -s /bin/bash -m -d /home/${USERNAME} ${USERNAME} |
| 71 | + |
| 72 | +# Grant it passwordless admin permissions |
| 73 | +RUN usermod -aG sudo ${USERNAME} && \ |
| 74 | + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 75 | + |
| 76 | +# Copy required files to container |
| 77 | +COPY --from=docker_root ./motd.txt /etc/motd |
| 78 | +COPY --from=docker_root ./scripts/entrypoint /usr/local/bin/entrypoint |
| 79 | +COPY --from=docker_root ./scripts/guix-check /usr/local/bin/guix-check |
| 80 | +COPY --from=docker_root ./scripts/guix-start /usr/local/bin/guix-start |
| 81 | + |
| 82 | +# Create directory for mounting and grant necessary permissions |
| 83 | +RUN mkdir -p /src/dash && \ |
| 84 | + chown -R ${USER_ID}:${GROUP_ID} /src |
| 85 | +WORKDIR "/src/dash" |
| 86 | + |
| 87 | +# Switch to unprivileged context |
| 88 | +USER ${USERNAME} |
| 89 | + |
| 90 | +# Set entrypoint to copied file |
| 91 | +ENTRYPOINT ["/usr/local/bin/entrypoint"] |
0 commit comments