|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +ARG UID=1000 |
| 3 | +ARG VERSION=EDGE |
| 4 | +ARG RELEASE=0 |
| 5 | +ARG BASE_IMAGE=registry.fedoraproject.org/fedora-toolbox:41 |
| 6 | + |
| 7 | +######################################## |
| 8 | +# Base stage |
| 9 | +######################################## |
| 10 | +FROM ${BASE_IMAGE} AS base |
| 11 | + |
| 12 | +# Set dnf config |
| 13 | +RUN cat <<-"EOF" > /etc/dnf/dnf.conf |
| 14 | +[main] |
| 15 | +install_weak_deps=False |
| 16 | +tsflags=nodocs |
| 17 | +EOF |
| 18 | + |
| 19 | +######################################## |
| 20 | +# Font unpack stage |
| 21 | +######################################## |
| 22 | +FROM base AS font-unpacker |
| 23 | + |
| 24 | +WORKDIR /fonts |
| 25 | + |
| 26 | +ADD https://github.com/ButTaiwan/iansui/releases/download/v1.000/iansui.zip /tmp/iansui.zip |
| 27 | + |
| 28 | +ADD https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/Hack.zip /tmp/hack.zip |
| 29 | + |
| 30 | +RUN unzip -uo /tmp/iansui.zip -d /fonts/iansui && \ |
| 31 | + unzip -uo /tmp/hack.zip -d /fonts/hack |
| 32 | + |
| 33 | +######################################## |
| 34 | +# Host runner stage |
| 35 | +######################################## |
| 36 | +FROM base AS host-runner |
| 37 | + |
| 38 | +WORKDIR /host-runner |
| 39 | + |
| 40 | +RUN cat <<-"EOF" > /host-runner/host-runner |
| 41 | +#!/bin/bash |
| 42 | +executable="$(basename ${0})" |
| 43 | +exec flatpak-spawn --host "${executable}" "${@}" |
| 44 | +EOF |
| 45 | + |
| 46 | +# Setup host-runner script and symlinks |
| 47 | +RUN bins=( \ |
| 48 | + "flatpak" \ |
| 49 | + "podman" \ |
| 50 | + "docker" \ |
| 51 | + "rpm-ostree" \ |
| 52 | + "systemctl" \ |
| 53 | + "xdg-open" \ |
| 54 | + "kitty" \ |
| 55 | + ); \ |
| 56 | + for f in "${bins[@]}"; do \ |
| 57 | + ln -s host-runner "/host-runner/$f";\ |
| 58 | + done |
| 59 | + |
| 60 | +######################################## |
| 61 | +# Final stage |
| 62 | +######################################## |
| 63 | +FROM base AS final |
| 64 | + |
| 65 | +# Create directories with correct permissions |
| 66 | +ARG UID |
| 67 | +RUN install -d -m 775 -o $UID -g 0 /licenses |
| 68 | + |
| 69 | +# Copy licenses (OpenShift Policy) |
| 70 | +COPY --chown=$UID:0 --chmod=775 LICENSE /licenses/Containerfile.LICENSE |
| 71 | + |
| 72 | +# COPY host-runner |
| 73 | +COPY --chown=$UID:0 --chmod=775 --from=host-runner /host-runner /usr/local/bin |
| 74 | + |
| 75 | +# RUN mount cache for multi-arch: https://github.com/docker/buildx/issues/549#issuecomment-1788297892 |
| 76 | +ARG TARGETARCH |
| 77 | +ARG TARGETVARIANT |
| 78 | + |
| 79 | +# Make sure the cache is refreshed |
| 80 | +ARG RELEASE |
| 81 | + |
| 82 | +# Install utilities |
| 83 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 84 | + dnf -y upgrade && \ |
| 85 | + dnf -y install \ |
| 86 | + xdg-utils \ |
| 87 | + jq |
| 88 | + |
| 89 | +# Fonts |
| 90 | +COPY --chown=$UID:0 --chmod=775 --from=font-unpacker /fonts /usr/local/share/fonts |
| 91 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 92 | + dnf -y install \ |
| 93 | + google-noto-sans-cjk-fonts \ |
| 94 | + cascadia-fonts-all \ |
| 95 | + hanamin-fonts |
| 96 | + |
| 97 | +# Install os keyring |
| 98 | +#! Following this guide to setup os keyring to use gnome-libsecret: |
| 99 | +# https://code.visualstudio.com/docs/editor/settings-sync#_recommended-configure-the-keyring-to-use-with-vs-code |
| 100 | +ENV GCM_CREDENTIAL_STORE=gpg |
| 101 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 102 | + dnf -y install seahorse |
| 103 | + |
| 104 | +# Install .NET |
| 105 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 106 | + dnf -y install dotnet-sdk-8.0 |
| 107 | + |
| 108 | +# Install Rustup |
| 109 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 110 | + dnf -y install rustup |
| 111 | + |
| 112 | +# Install Java 17 (JetBrains loves this) |
| 113 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 114 | + dnf -y install java-17-openjdk |
| 115 | + |
| 116 | +# Install git-credential-manager (This needs .NET 8) |
| 117 | +RUN curl -L https://aka.ms/gcm/linux-install-source.sh | sh && \ |
| 118 | +git-credential-manager configure |
| 119 | + |
| 120 | +# Install aria2 |
| 121 | +RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \ |
| 122 | + dnf -y install aria2 |
| 123 | + |
| 124 | +# Copy toolbox runners |
| 125 | +COPY --chown=$UID:0 --chmod=775 video/runner /copy-to-host |
| 126 | + |
| 127 | +ARG VERSION |
| 128 | +ARG RELEASE |
| 129 | +LABEL name="jim60105/toolbx" \ |
| 130 | + org.opencontainers.image.name="jim60105/toolbx" \ |
| 131 | + # Authors for toolbox |
| 132 | + vendor="Fedora Project" \ |
| 133 | + # Maintainer for this container image |
| 134 | + maintainer="jim60105" \ |
| 135 | + # Containerfile source repository |
| 136 | + url="https://github.com/jim60105/toolbx" \ |
| 137 | + version=${VERSION} \ |
| 138 | + # This should be a number, incremented with each change |
| 139 | + release=${RELEASE} \ |
| 140 | + io.k8s.display-name="toolbx" \ |
| 141 | + summary="toolbx: My Personal Fedora Toolbox (Containerfile)" \ |
| 142 | + description="Toolbx is a tool for Linux, which allows the use of interactive command line environments for software development and troubleshooting the host operating system, without having to install software on the host. These are my personal Fedora toolbox images, which I use for development and daily usage. For more information about this tool, please visit the following website: https://github.com/jim60105/toolbx" \ |
| 143 | + license="GPL-3.0" \ |
| 144 | + org.opencontainers.image.license="GPL-3.0" |
0 commit comments