Skip to content

Commit 2c0c2a5

Browse files
committed
ci: using buildx with caching support, to build images
1 parent bfe04e4 commit 2c0c2a5

3 files changed

Lines changed: 48 additions & 31 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,44 @@ jobs:
4949
uses: actions/checkout@v3
5050

5151
- name: Set up Docker
52-
uses: docker/setup-docker-action@v4
53-
54-
- name: Log in to the Container registry
55-
uses: docker/login-action@v3
52+
uses: nxtcoder17/actions/setup-docker@main
5653
with:
57-
registry: ${{ env.REGISTRY_URL }}
58-
username: ${{ env.REGISTRY_USERNAME }}
59-
password: ${{ env.REGISTRY_PASSWORD }}
54+
docker_registry: ${{ env.REGISTRY_URL }}
55+
docker_username: ${{ env.REGISTRY_USERNAME }}
56+
docker_password: ${{ env.REGISTRY_PASSWORD }}
57+
58+
# - name: Log in to the Container registry
59+
# uses: docker/login-action@v3
60+
# with:
61+
# registry: ${{ env.REGISTRY_URL }}
62+
# username: ${{ env.REGISTRY_USERNAME }}
63+
# password: ${{ env.REGISTRY_PASSWORD }}
64+
65+
# - name: Build Image
66+
# id: build_image
67+
# shell: bash
68+
# env:
69+
# IMAGE: "ghcr.io/${{ github.repository}}:${{matrix.fedora_version}}"
70+
# run: |+
71+
# docker buildx build \
72+
# -t $IMAGE -f ./Containerfile . --build-arg FEDORA_VERSION=${{ matrix.fedora_version }}
73+
# docker push $IMAGE
6074

6175
- name: Build Image
6276
id: build_image
6377
shell: bash
6478
env:
6579
IMAGE: "ghcr.io/${{ github.repository}}:${{matrix.fedora_version}}"
80+
buildx_cache_master: "ghcr.io/${{ github.repository }}:buildx-cache-master"
81+
buildx_cache: "ghcr.io/${{ github.repository }}:buildx-cache-${{matrix.fedora_version}}"
6682
run: |+
67-
docker build -t $IMAGE -f ./Containerfile . --build-arg FEDORA_VERSION=${{ matrix.fedora_version }}
68-
docker push $IMAGE
83+
docker buildx build -t $IMAGE -f ./Containerfile \
84+
--build-arg FEDORA_VERSION="${{ matrix.fedora_version }}" \
85+
--cache-to type=registry,ref="$buildx_cache",mode=max,compression=zstd,compression-level=13,force-compression=true \
86+
--cache-from type=registry,ref="$buildx_cache" \
87+
--cache-from type=registry,ref="$buildx_cache_master" \
88+
--output=type=image,compression=zstd,force-compression=true,compression-level=13,push=true \
89+
.
6990
7091
# - name: Build Image
7192
# id: build_image

Containerfile

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ ARG NVIDIA_AKMODS_DIGEST=""
1717

1818
# Stage 1: Clone ublue-os/main and merge packages
1919
FROM alpine/git AS buildctx
20-
ARG UBLUE_MAIN_VERSION="main"
21-
2220
RUN apk add --no-cache yq jq
2321

2422
RUN <<EOF
25-
echo "Cloning ublue-os/main repo (branch: $UBLUE_MAIN_VERSION)..."
26-
git clone --depth=1 --branch "${UBLUE_MAIN_VERSION}" \
23+
git_branch="main"
24+
echo "Cloning ublue-os/main repo (branch: $git_branch)..."
25+
git clone --depth=1 --branch "${git_branch}" \
2726
https://github.com/ublue-os/main.git ./ublue-os
2827
mv ublue-os/sys_files /
2928
mv ublue-os/build_files/* /
@@ -36,23 +35,15 @@ RUN <<EOF
3635
set -ex
3736
echo "Merging ublue packages with custom packages..."
3837

39-
# Extract ublue packages for "all" and "silverblue" sections
40-
UBLUE_ALL=$(jq -r '.all.include.all[]' /ublue-packages.json)
41-
UBLUE_SILVERBLUE=$(jq -r '.all.include.silverblue[]' /ublue-packages.json)
42-
4338
# Convert your YAML packages to JSON array
44-
YOUR_PACKAGES=$(yq -o=json '.packages' /packages.yml)
45-
46-
# Merge all three lists, deduplicate and sort
47-
jq -n \
48-
--arg ublue_all "$UBLUE_ALL" \
49-
--arg ublue_sb "$UBLUE_SILVERBLUE" \
50-
--argjson yours "$YOUR_PACKAGES" \
51-
'{"packages": (($ublue_all | split("\n")) + ($ublue_sb | split("\n")) + $yours | unique | sort)}' \
52-
> /packages.json
53-
54-
echo "Final package list ($(jq -r '.packages | length' /packages.json) packages):"
55-
jq -r '.packages[]' /packages.json
39+
yq -o=json /packages.yml > /additional-packages.json
40+
41+
jq --slurpfile pkgs /additional-packages.json \
42+
'.all.include.silverblue += $pkgs[0].packages' \
43+
/ublue-packages.json > /packages.json
44+
45+
echo "also installing user packages"
46+
jq -r '.all.include.silverblue' </packages.json
5647
EOF
5748

5849
# Stage 2: Get kernel modules from ublue-os
@@ -82,16 +73,19 @@ set -ouex pipefail
8273
rm -f /usr/bin/chsh /usr/bin/lchsh
8374

8475
echo "Running ublue-os build scripts..."
85-
8676
/ctx/install.sh
8777

8878
AKMODNV_PATH=/tmp/akmods-nv-rpms /ctx/nvidia-install.sh
8979

9080
/ctx/initramfs.sh
9181
/ctx/post-install.sh
92-
9382
EOF
9483

9584
# Validate the image
9685
RUN ["bootc", "container", "lint"]
9786

87+
# RUN rpm-ostree override remove firefox firefox-langpacks
88+
# RUN rpm-ostree cleanup -m
89+
#
90+
# RUN sed -i "s|^NAME=.*|NAME=nxtcoder17 edition silverblue ${FEDORA_VERSION}|" /usr/lib/os-release
91+
# RUN sed -i "s|^PRETTY_NAME=.*|PRETTY_NAME=nxtcoder17 edition silverblue ${FEDORA_VERSION}|" /usr/lib/os-release

packages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
packages:
2+
- docker
23
- hyprland
4+
- distrobox

0 commit comments

Comments
 (0)