From cb5f31a934a18bcfb68703738ee7ab227791b2b9 Mon Sep 17 00:00:00 2001 From: "Sean P. Kane" Date: Mon, 26 Feb 2024 17:26:46 -0800 Subject: [PATCH 1/4] tweaks --- Dockerfile | 4 +++- build.sh | 19 +++++++++++-------- languages/go.dockerfile | 4 ++-- languages/rust.dockerfile | 4 +++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15d244d..e59d1ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,5 +14,7 @@ RUN pacman -R --noconfirm podman distrobox crun steamos-kdumpst-layer jupiter-st && pacman -S --noconfirm gcc make autoconf automake bison fakeroot flex m4 tpm2-tss \ && yes | pacman -Scc -FROM scratch +FROM scratch as final + COPY --from=builder / / + diff --git a/build.sh b/build.sh index 77dd624..fa1d587 100755 --- a/build.sh +++ b/build.sh @@ -1,15 +1,18 @@ #!/bin/bash set -e -LOOP=$(losetup --find --partscan --show ./steamos_image/disk.img) -mkdir -p ./steamos -mount ${LOOP}p3 ./steamos -unmountimg() { - umount ./steamos - losetup -d $LOOP +sudo losetup + +LOOP=$(sudo losetup --find --partscan --show ./steamos_image/disk.img) +mkdir -p ${PWD}/steamos +sudo btrfstune -M $(uuidgen) ${LOOP}p3 +sudo mount ${LOOP}p3 ${PWD}/steamos +unmount_img() { + sudo umount ${PWD}/steamos + sudo losetup -d $LOOP } trap unmountimg ERR -docker build -t ghcr.io/steamdeckhomebrew/holo-base:latest . +sudo podman build -t docker.io/spkane/holo-base:latest . -unmountimg +unmount_img diff --git a/languages/go.dockerfile b/languages/go.dockerfile index 69e67bb..3707942 100644 --- a/languages/go.dockerfile +++ b/languages/go.dockerfile @@ -1,3 +1,3 @@ -FROM ghcr.io/steamdeckhomebrew/holo-base:latest +FROM docker.io/spkane/holo-base:latest -RUN pacman -Sy --noconfirm go go-tools \ No newline at end of file +RUN pacman -Sy --noconfirm go go-tools diff --git a/languages/rust.dockerfile b/languages/rust.dockerfile index cad54e2..e07cd50 100644 --- a/languages/rust.dockerfile +++ b/languages/rust.dockerfile @@ -1,8 +1,10 @@ -FROM ghcr.io/steamdeckhomebrew/holo-base:latest +FROM docker.io/spkane/holo-base:latest ENV RUSTUP_HOME=/.rustup ENV CARGO_HOME=/.cargo RUN mkdir /.rustup && chmod -R 777 /.rustup RUN mkdir /.cargo && chmod -R 777 /.cargo + RUN pacman -Sy --noconfirm rustup && rustup install stable + From 202c64948d7e559a60ab9b868f57769545bf248a Mon Sep 17 00:00:00 2001 From: "Sean P. Kane" Date: Tue, 27 Feb 2024 09:25:28 -0800 Subject: [PATCH 2/4] Make it more flexible --- .github/workflows/build.yml | 11 +++++++--- .gitignore | 3 ++- README.md | 31 +++++++++++++++++++++++++++- build.sh | 36 +++++++++++++++++++++++++-------- download.sh | 8 +++++--- example.env | 3 +++ languages/build.sh | 40 +++++++++++++++++++++++++++++++++++++ languages/go.dockerfile | 4 +++- languages/push_image.sh | 29 +++++++++++++++++++++++++++ languages/rust.dockerfile | 4 +++- push_image.sh | 24 ++++++++++++++++++++++ 11 files changed, 175 insertions(+), 18 deletions(-) create mode 100644 example.env create mode 100755 languages/build.sh create mode 100755 languages/push_image.sh create mode 100755 push_image.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07966c0..f89e7fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,20 +27,24 @@ jobs: run: ./download.sh - name: Build base image - run: sudo ./build.sh + run: | + cp example.env .env + sudo ./build.sh - name: Cleanup SteamOS image run: rm -rf ./steamos_image ./steamos - name: Build Rust toolchain image run: | + cp example.env .env cd languages - docker build -t ghcr.io/steamdeckhomebrew/holo-toolchain-rust:latest -f ./rust.dockerfile . + ./build.sh rust - name: Build Go toolchain image run: | + cp example.env .env cd languages - docker build -t ghcr.io/steamdeckhomebrew/holo-toolchain-go:latest -f ./go.dockerfile . + ./build.sh go - name: Wait for other runs to complete uses: softprops/turnstyle@v1 @@ -59,3 +63,4 @@ jobs: - name: Log out of GitHub Container Registry run: | docker logout ghcr.io + diff --git a/.gitignore b/.gitignore index 33ac99a..0255f15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ steamos -steamos_image \ No newline at end of file +steamos_image +.env diff --git a/README.md b/README.md index 06370e8..163a3d6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # holo-docker -Docker images of SteamOS Holo +Linux container images of SteamOS Holo + +## Getting Started + +```sh +./download.sh +./build.sh +./push_image.sh +``` + +### SteamDeck + +These scripts should work just fine on an actual SteamDeck, assuming that it is up-to-date. However you will need to do just a little bit of setup, as the default location for container storage is much too small for this. + +```sh +mkdir ~/containers +sudo cp -a /var/lib/container/storage ~/containers/storage +sudo vim /etc/containers/storage.conf +``` + +Change the line that reads: + +- `graphroot = "/var/lib/containers/storage"` + +to + +- `graphroot = "/home/deck/containers/storage"` + +You will also need to use the `sudo` command when running the build and push scripts. + diff --git a/build.sh b/build.sh index fa1d587..31a03c0 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,38 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e -sudo losetup +set -a +if [[ -f ${PWD}/.env ]]; then + source ${PWD}/.env +else + echo "[ERROR] Please copy 'example.env' to '.env' and edit values as desired." + exit 1 +fi +set +a + +losetup -LOOP=$(sudo losetup --find --partscan --show ./steamos_image/disk.img) +LOOP=$(losetup --find --partscan --show ./steamos_image/disk.img) mkdir -p ${PWD}/steamos -sudo btrfstune -M $(uuidgen) ${LOOP}p3 -sudo mount ${LOOP}p3 ${PWD}/steamos +btrfstune -M $(uuidgen) ${LOOP}p3 # This allows us to mount this partition even if we are on a real SteamDeck. +mount ${LOOP}p3 ${PWD}/steamos + unmount_img() { - sudo umount ${PWD}/steamos - sudo losetup -d $LOOP + umount ${PWD}/steamos + losetup -d $LOOP } + trap unmountimg ERR -sudo podman build -t docker.io/spkane/holo-base:latest . +if command -v "docker" &> /dev/null; then + docker build -t ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base:${IMAGE_TAG} . +elif command -v "podman" &> /dev/null; then + podman build -t ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base:${IMAGE_TAG} . +else + echo "[ERROR] You must have 'docker' or 'podman' installed." + exit 1 +fi unmount_img + diff --git a/download.sh b/download.sh index 57df19c..2eb3d0f 100755 --- a/download.sh +++ b/download.sh @@ -1,10 +1,12 @@ -#!/bin/sh +#!/usr/bin/env bash + set -e -# these are hardcoded and can be found in ~/.netrc +# These are hardcoded and can be found in ~/.netrc on the SteamDeck filesystem image AUTH="jupiter-image-2021:e54fe7f0-756e-46e1-90d2-7843cda0ac01" FILE=$(curl -sS --user $AUTH "https://steamdeck-atomupd.steamos.cloud/updates?product=steamos&release=holo&variant=steamdeck&arch=amd64&version=snapshot&buildid=20220526.1&checkpoint=False&estimated_size=0" | jq -r ".minor.candidates[0].update_path" | sed 's/\.raucb/\.img.zip/') echo "Downloading image $FILE" curl --user $AUTH "https://steamdeck-images.steamos.cloud/$FILE" -o ./steamos.zip unzip ./steamos.zip -d ./steamos_image -rm ./steamos.zip \ No newline at end of file +rm ./steamos.zip + diff --git a/example.env b/example.env new file mode 100644 index 0000000..965b332 --- /dev/null +++ b/example.env @@ -0,0 +1,3 @@ +IMAGE_BASE="ghcr.io/steamdeckhomebrew" +IMAGE_NAME_ROOT="holo" +IMAGE_TAG="latest" diff --git a/languages/build.sh b/languages/build.sh new file mode 100755 index 0000000..d651bce --- /dev/null +++ b/languages/build.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -e + +if [[ $# != 1 ]]; then + echo "[ERROR] Exactly one argument is expected that matches the first part of one of the dockerfile names (e.g. 'go')" + exit 1 +fi + +DIR="$(dirname "$(realpath "$0")")" + +cd ${DIR} + +if [[ ! -f "${1}.dockerfile" ]]; then + echo "[ERROR] Could not find '${1}.dockerfile' in the same directory as this script." + exit 1 +fi + +set -a +if [[ -f ${PWD}/../.env ]]; then + source ${PWD}/../.env +else + echo "[ERROR] Please copy 'example.env' to '.env' in the repo root and edit values as desired." + exit 1 +fi +set +a + +if command -v "docker" &> /dev/null; then + docker build -f "${1}.dockerfile" \ + --build-arg="image_name=${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base" \ + -t ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-toolchain-${1}:${IMAGE_TAG} . +elif command -v "podman" &> /dev/null; then + podman build -f "${1}.dockerfile" \ + --build-arg="image_name=${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base" \ + -t ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-toolchain-${1}:${IMAGE_TAG} . +else + echo "[ERROR] You must have 'docker' or 'podman' installed." + exit 1 +fi + diff --git a/languages/go.dockerfile b/languages/go.dockerfile index 3707942..75ced94 100644 --- a/languages/go.dockerfile +++ b/languages/go.dockerfile @@ -1,3 +1,5 @@ -FROM docker.io/spkane/holo-base:latest +ARG image_name + +FROM ${image_name} RUN pacman -Sy --noconfirm go go-tools diff --git a/languages/push_image.sh b/languages/push_image.sh new file mode 100755 index 0000000..c380518 --- /dev/null +++ b/languages/push_image.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +if [[ $# != 1 ]]; then + echo "[ERROR] Exactly one argument is expected that matches the first part of one of the dockerfile names (e.g. 'go')" + exit 1 +fi + +set -a +if [[ -f ${PWD}/../.env ]]; then + source ${PWD}/../.env +else + echo "[ERROR] Please copy 'example.env' to '.env' and edit values as desired." + exit 1 +fi +set +a + +if command -v "docker" &> /dev/null; then + docker login ${IMAGE_BASE} + docker image push ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-toolchain-${1}:${IMAGE_TAG} +elif command -v "podman" &> /dev/null; then + podman login ${IMAGE_BASE} + podman image push ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-toolchain-${1}:${IMAGE_TAG} +else + echo "[ERROR] You must have 'docker' or 'podman' installed." + exit 1 +fi + diff --git a/languages/rust.dockerfile b/languages/rust.dockerfile index e07cd50..e2f67a3 100644 --- a/languages/rust.dockerfile +++ b/languages/rust.dockerfile @@ -1,4 +1,6 @@ -FROM docker.io/spkane/holo-base:latest +ARG image_name + +FROM ${image_name} ENV RUSTUP_HOME=/.rustup ENV CARGO_HOME=/.cargo diff --git a/push_image.sh b/push_image.sh new file mode 100755 index 0000000..11c091e --- /dev/null +++ b/push_image.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +set -a +if [[ -f ${PWD}/.env ]]; then + source ${PWD}/.env +else + echo "[ERROR] Please copy 'example.env' to '.env' and edit values as desired." + exit 1 +fi +set +a + +if command -v "docker" &> /dev/null; then + docker login ${IMAGE_BASE%%/*} + docker image push ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base:${IMAGE_TAG} +elif command -v "podman" &> /dev/null; then + podman login ${IMAGE_BASE%%/*} + podman image push ${IMAGE_BASE}/${IMAGE_NAME_ROOT}-base:${IMAGE_TAG} +else + echo "[ERROR] You must have 'docker' or 'podman' installed." + exit 1 +fi + From 96dfdc7f873e28e8d62aae84a4297d71bc444cb1 Mon Sep 17 00:00:00 2001 From: "Sean P. Kane" Date: Tue, 27 Feb 2024 09:30:41 -0800 Subject: [PATCH 3/4] Clarification --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 163a3d6..eaf8ea3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Linux container images of SteamOS Holo ### SteamDeck -These scripts should work just fine on an actual SteamDeck, assuming that it is up-to-date. However you will need to do just a little bit of setup, as the default location for container storage is much too small for this. +These scripts should work just fine on an actual SteamDeck, assuming that SteamOS is up-to-date, and you are comfortable using the SteamDeck terminal. However you will need to do just a little bit of setup, as the default location for container storage is much too small for this. ```sh mkdir ~/containers @@ -27,5 +27,5 @@ to - `graphroot = "/home/deck/containers/storage"` -You will also need to use the `sudo` command when running the build and push scripts. +You will also need to use the `sudo` command when running the top-level build and push scripts. From d0e9a572edd19e4157bca2675d259802b24bf570 Mon Sep 17 00:00:00 2001 From: "Sean P. Kane" Date: Tue, 15 Oct 2024 11:48:19 -0700 Subject: [PATCH 4/4] Fix FROM/AS capitalization --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e59d1ab..e3d697d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM scratch as builder +FROM scratch AS builder ADD ./steamos / ADD ./steamos/usr/share/factory / @@ -14,7 +14,7 @@ RUN pacman -R --noconfirm podman distrobox crun steamos-kdumpst-layer jupiter-st && pacman -S --noconfirm gcc make autoconf automake bison fakeroot flex m4 tpm2-tss \ && yes | pacman -Scc -FROM scratch as final +FROM scratch AS final COPY --from=builder / /