diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a7fb082 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Create and Publish a Docker image + +on: + push: + branches: [ master ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc4b1e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +FROM archlinux:base-devel AS build + +# Setup sudo user & install dependencies +RUN pacman -Syu --noconfirm git pacutils perl-json-xs devtools pacman-contrib ninja cargo && \ + echo '%wheel ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers && \ + useradd --uid 1000 --shell /bin/bash --groups wheel --create-home build + +USER build + +WORKDIR /home/build + +# Build aurutils & aurto +RUN curl -L https://aur.archlinux.org/cgit/aur.git/snapshot/aurutils.tar.gz | tar xz && \ + cd aurutils && \ + gpg --recv-keys DBE7D3DD8C81D58D0A13D0E76BC26A17B9B7018A && \ + makepkg -i --noconfirm && \ + cd .. && \ + curl -L https://aur.archlinux.org/cgit/aur.git/snapshot/aurto.tar.gz | tar xz && \ + cd aurto && \ + makepkg -i --noconfirm + +FROM archlinux:latest + +ENV USER_ID="1002" \ + USER=aurto + +WORKDIR / + +# Remove unnecessary units +RUN rm -f /lib/systemd/system/multi-user.target.wants/* \ + /etc/systemd/system/*.wants/* \ + /lib/systemd/system/local-fs.target.wants/* \ + /lib/systemd/system/sockets.target.wants/*udev* \ + /lib/systemd/system/sockets.target.wants/*initctl* \ + /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \ + /lib/systemd/system/systemd-update-utmp* + +# Install dependencies and setup sudo user +RUN pacman -Syu --needed --noconfirm base-devel sudo pacman-contrib && \ + echo '%wheel ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers && \ + useradd --uid ${USER_ID} --shell /bin/bash --groups wheel --create-home aurto + +WORKDIR /tmp + +# Copy aurutils & aurto from build stage +COPY --from=build /home/build/aurutils/aurutils-*.pkg.tar.zst /tmp/ +COPY --from=build /home/build/aurto/aurto-*.pkg.tar.zst /tmp/ + +# Install aurto & aurutils +RUN pacman -U --noconfirm /tmp/aurutils-*.pkg.tar.zst && \ + pacman -U --noconfirm /tmp/aurto-*.pkg.tar.zst && \ + + # Disable chroot for aurto + touch /usr/lib/aurto/conf-disable-chroot && \ + + # Cleanup + rm -r /tmp/* && \ + paccache -rk0 && \ + + # Setup pacman hook + mkdir -p /etc/pacman.d/hooks/ && \ + echo -e "[Trigger]\nType = Package\nOperation = Remove\nOperation = Install\nOperation = Upgrade\nTarget = *\n\n[Action]\nDescription = Removing unnecessary cached files (keeping the latest one)...\nWhen = PostTransaction\nExec = /usr/bin/paccache -rk0" > /etc/pacman.d/hooks/pacman-cache-cleanup.hook + +WORKDIR /home/aurto + +VOLUME ["/tmp", "/run", "/run/lock", "/etc/aurto", "/var/cache/pacman/aurto"] + +CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] \ No newline at end of file diff --git a/README.md b/README.md index 6376431..8a6b4d7 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,11 @@ Remove `/etc/aurto/trusted-users` to trust everyone. **aurto** builds packages in a chroot using `/etc/aurto/makepkg-chroot.conf` & `/etc/aurto/pacman-chroot.conf`. These can be customized in the same way as the main _makepkg.conf, pacman.conf_, for example to change compression. +# Running on docker +**aurto** can also be ran on docker to allow for installation on non Arch distros for hosting a aur repo, etc. + +You can find the documentation on how to install it [here](./dockerREADME.md). + # Limitations & Security **aurto** automatically builds and regularly re-builds updated remote code from the aur. Code is _built_ in a clean chroot, but presumably will eventually be installed to your system. diff --git a/dockerREADME.md b/dockerREADME.md new file mode 100644 index 0000000..f31b57c --- /dev/null +++ b/dockerREADME.md @@ -0,0 +1,30 @@ +# aurto with docker + +After installing docker on your machine, run this command to create the container: +```sh +docker run -d --name aurto-docker \ + --privileged --cap-add SYS_ADMIN --security-opt seccomp=unconfined \ + --cgroup-parent=docker.slice --cgroupns private \ + --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \ + -v aurto_db:/var/cache/pacman/aurto \ + -v aurto_config:/etc/aurto \ + ghcr.io/alexheretic/aurto:master +``` + +> Make sure to replace **aurto_db** and **aurto_config** with an actual path if you don't want it to store the pacman repo and config files in a docker volume + +Then running the commands like a normal installation, first initialise the 'aurto' repo & systemd timers. +```sh +docker exec -it --user aurto aurto-docker aurto init +``` + +Recommended: Add **aurto** to the 'aurto' repo to provide self updates. +```sh +docker exec -it --user aurto aurto-docker aurto add aurto +``` + +Also recommended: Add an alias to .bashrc so you only have to write aurto instead of the full docker command. + +```sh +alias aurto="docker exec -it --user aurto aurto-docker aurto" +``` \ No newline at end of file