Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the image name configurable and get things working on the SteamDeck #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,3 +63,4 @@ jobs:
- name: Log out of GitHub Container Registry
run: |
docker logout ghcr.io

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
steamos
steamos_image
steamos_image
.env
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM scratch as builder
FROM scratch AS builder
ADD ./steamos /
ADD ./steamos/usr/share/factory /

Expand All @@ -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 / /

31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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 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
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 top-level build and push scripts.

37 changes: 30 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
#!/bin/bash
#!/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

losetup

LOOP=$(losetup --find --partscan --show ./steamos_image/disk.img)
mkdir -p ./steamos
mount ${LOOP}p3 ./steamos
unmountimg() {
umount ./steamos
mkdir -p ${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() {
umount ${PWD}/steamos
losetup -d $LOOP
}

trap unmountimg ERR

docker build -t ghcr.io/steamdeckhomebrew/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

unmountimg
8 changes: 5 additions & 3 deletions download.sh
Original file line number Diff line number Diff line change
@@ -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
rm ./steamos.zip

3 changes: 3 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IMAGE_BASE="ghcr.io/steamdeckhomebrew"
IMAGE_NAME_ROOT="holo"
IMAGE_TAG="latest"
40 changes: 40 additions & 0 deletions languages/build.sh
Original file line number Diff line number Diff line change
@@ -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

6 changes: 4 additions & 2 deletions languages/go.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM ghcr.io/steamdeckhomebrew/holo-base:latest
ARG image_name

RUN pacman -Sy --noconfirm go go-tools
FROM ${image_name}

RUN pacman -Sy --noconfirm go go-tools
29 changes: 29 additions & 0 deletions languages/push_image.sh
Original file line number Diff line number Diff line change
@@ -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

6 changes: 5 additions & 1 deletion languages/rust.dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM ghcr.io/steamdeckhomebrew/holo-base:latest
ARG image_name

FROM ${image_name}

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

24 changes: 24 additions & 0 deletions push_image.sh
Original file line number Diff line number Diff line change
@@ -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