Skip to content

Commit 21b7e38

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

2 files changed

Lines changed: 44 additions & 25 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-master"
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: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,15 @@ RUN <<EOF
3636
set -ex
3737
echo "Merging ublue packages with custom packages..."
3838

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-
4339
# 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
40+
yq -o=json /packages.yml > /additional-packages.json
41+
42+
jq --slurpfile pkgs /additional-packages.json \
43+
'.all.include.silverblue += $pkgs[0].packages' \
44+
/ublue-packages.json > /packages.json
45+
46+
echo "also installing user packages"
47+
jq -r '.all.include.silverblue' </packages.json
5648
EOF
5749

5850
# Stage 2: Get kernel modules from ublue-os
@@ -92,6 +84,12 @@ AKMODNV_PATH=/tmp/akmods-nv-rpms /ctx/nvidia-install.sh
9284

9385
EOF
9486

87+
RUN rpm-ostree override remove firefox firefox-langpacks
88+
RUN rpm-ostree install distrobox docker hyprland
89+
RUN sed -i "s|^NAME=.*|NAME=nxtcoder17 edition silverblue ${FEDORA_VERSION}|" /usr/lib/os-release
90+
91+
RUN sed -i "s|^PRETTY_NAME=.*|PRETTY_NAME=nxtcoder17 edition silverblue ${FEDORA_VERSION}|" /usr/lib/os-release
92+
9593
# Validate the image
9694
RUN ["bootc", "container", "lint"]
9795

0 commit comments

Comments
 (0)