diff --git a/mk/podman.mk b/mk/podman.mk index 64c6049c..43d949d3 100644 --- a/mk/podman.mk +++ b/mk/podman.mk @@ -14,6 +14,20 @@ else PODMAN_VOLUME_FLAG= endif +# Cache layers to redox-os docker hub +PODMAN_CACHE= +PODMAN_CACHE_PATH=docker.io/redoxos/$(IMAGE_TAG) + +PODMAN_CACHE_PULL?=1 +ifeq ($(PODMAN_CACHE_PULL),1) +PODMAN_CACHE+=--cache-from=$(PODMAN_CACHE_PATH) +endif + +PODMAN_CACHE_PUSH?=0 +ifeq ($(PODMAN_CACHE_PUSH),1) +PODMAN_CACHE+=--cache-to=$(PODMAN_CACHE_PATH) +endif + ## Podman Home Directory PODMAN_HOME=$(ROOT)/build/podman ## Podman command with its many arguments @@ -58,8 +72,7 @@ ifeq ($(PODMAN_BUILD),1) -podman image rm --force $(IMAGE_TAG) || true mkdir -p $(PODMAN_HOME) @echo "Building Podman image. This may take some time." - cat $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) --tag $(IMAGE_TAG) - $(PODMAN_RUN) bash -e podman/rustinstall.sh + cat $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) $(PODMAN_CACHE) --tag $(IMAGE_TAG) mkdir -p build touch $@ @echo "Podman ready!" @@ -67,6 +80,9 @@ else @echo PODMAN_BUILD=$(PODMAN_BUILD), container not required. endif +container_push: build/container.tag + podman push $(IMAGE_TAG) $(PODMAN_CACHE_PATH) + KERNEL_PATH := recipes/core/kernel KERNEL_PATH_SOURCE := $(ROOT)/$(KERNEL_PATH)/source KERNEL_PATH_TARGET := $(ROOT)/$(KERNEL_PATH)/target/$(TARGET) diff --git a/podman/redox-base-containerfile b/podman/redox-base-containerfile index 7b058fc4..1b77e7a4 100644 --- a/podman/redox-base-containerfile +++ b/podman/redox-base-containerfile @@ -84,3 +84,20 @@ RUN apt-get update \ libc6-dev-i386 \ syslinux-utils \ ; fi + +RUN echo "Installing rust..." && \ + curl "https://sh.rustup.rs" -sSf | sh -s -- -y --default-toolchain stable --profile minimal + +RUN echo "Downloading sccache..." && \ + SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz" && \ + wget -qO- --show-progress "${SCCACHE_URL}" | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' + +RUN echo "Downloading just..." && \ + JUST_URL="https://github.com/casey/just/releases/download/1.45.0/just-1.45.0-$(uname -m)-unknown-linux-musl.tar.gz" && \ + wget -qO- --show-progress "${JUST_URL}" | tar -xz -C ~/.cargo/bin --wildcards 'just' + +RUN echo "Downloading cbindgen..." && \ + CBINDGEN_NAME="$( [ "$(uname -m)" = "x86_64" ] && echo "ubuntu22.04" || echo "ubuntu22.04-aarch64" )" && \ + CBINDGEN_URL="https://github.com/mozilla/cbindgen/releases/download/0.29.0/cbindgen-${CBINDGEN_NAME}" && \ + wget -qO- --show-progress "${CBINDGEN_URL}" > ~/.cargo/bin/cbindgen && \ + chmod +x ~/.cargo/bin/cbindgen diff --git a/podman/rustinstall.sh b/podman/rustinstall.sh deleted file mode 100755 index 31bd594c..00000000 --- a/podman/rustinstall.sh +++ /dev/null @@ -1,21 +0,0 @@ -#/usr/bin/env bash - -# This script install the Rust toolchain and the build system dependencies -# in Podman after the image has been built - -echo Installing rust... -curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal - -echo Downloading sccache... -SCCACHE_URL=https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(uname -m)-unknown-linux-musl.tar.gz -wget -qO- --show-progress $SCCACHE_URL | tar -xz -C ~/.cargo/bin --strip-components=1 --wildcards '*/sccache' - -echo Downloading just... -JUST_URL=https://github.com/casey/just/releases/download/1.45.0/just-1.45.0-$(uname -m)-unknown-linux-musl.tar.gz -wget -qO- --show-progress $JUST_URL | tar -xz -C ~/.cargo/bin --wildcards 'just' - -echo Downloading cbindgen... -CBINDGEN_NAME=$( [[ $(uname -m) = "x86_64" ]] && echo "ubuntu22.04" || echo "ubuntu22.04-aarch64" ) -CBINDGEN_URL=https://github.com/mozilla/cbindgen/releases/download/0.29.0/cbindgen-$CBINDGEN_NAME -wget -qO- --show-progress $CBINDGEN_URL > ~/.cargo/bin/cbindgen -chmod +x ~/.cargo/bin/cbindgen