-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for docker with README install instructions (#88)
* Add Dockerfile + workflow to build * Modify README to add docker install instructions * Mod README and add docker README * Make Dockerfile better * Update Dockerfile --------- Co-authored-by: Alex Butler <[email protected]>
- Loading branch information
1 parent
6749a49
commit 40d718f
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
``` |