Skip to content

Commit d76fbe6

Browse files
authored
devenv: Add a c10s version (#37)
Let's make this one a possible option too. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent b801fe3 commit d76fbe6

File tree

10 files changed

+323
-17
lines changed

10 files changed

+323
-17
lines changed

.github/workflows/build-devcontainer.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111

1212
env:
1313
REGISTRY: ghcr.io
14-
IMAGE_NAME: ${{ github.repository_owner }}/devenv-debian
1514

1615
jobs:
1716
validate-devcontainer:
@@ -33,13 +32,20 @@ jobs:
3332
strategy:
3433
fail-fast: false
3534
matrix:
35+
os: [debian, c10s]
3636
include:
3737
- runner: ubuntu-latest
3838
platform: linux/amd64
3939
arch: amd64
4040
- runner: ubuntu-24.04-arm
4141
platform: linux/arm64
4242
arch: arm64
43+
- os: debian
44+
containerfile: Containerfile.debian
45+
image_name: devenv-debian
46+
- os: c10s
47+
containerfile: Containerfile.c10s
48+
image_name: devenv-c10s
4349

4450
steps:
4551
- name: Checkout
@@ -59,17 +65,17 @@ jobs:
5965
id: meta
6066
uses: docker/metadata-action@v5
6167
with:
62-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }}
6369

6470
- name: Build and push by digest
6571
id: build
6672
uses: docker/build-push-action@v6
6773
with:
6874
context: devenv
69-
file: devenv/Containerfile
75+
file: devenv/${{ matrix.containerfile }}
7076
platforms: ${{ matrix.platform }}
7177
labels: ${{ steps.meta.outputs.labels }}
72-
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
78+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
7379

7480
- name: Export digest
7581
run: |
@@ -80,7 +86,7 @@ jobs:
8086
- name: Upload digest
8187
uses: actions/upload-artifact@v4
8288
with:
83-
name: digests-${{ matrix.arch }}
89+
name: digests-${{ matrix.os }}-${{ matrix.arch }}
8490
path: /tmp/digests/*
8591
if-no-files-found: error
8692
retention-days: 1
@@ -89,43 +95,51 @@ jobs:
8995
runs-on: ubuntu-latest
9096
needs: build
9197
if: github.event_name != 'pull_request'
98+
strategy:
99+
matrix:
100+
os: [debian, c10s]
101+
include:
102+
- os: debian
103+
image_name: devenv-debian
104+
- os: c10s
105+
image_name: devenv-c10s
92106
steps:
93107
- name: Download digests
94108
uses: actions/download-artifact@v4
95109
with:
96110
path: /tmp/digests
97-
pattern: digests-*
111+
pattern: digests-${{ matrix.os }}-*
98112
merge-multiple: true
99-
113+
100114
- name: Set up Docker Buildx
101115
uses: docker/setup-buildx-action@v3
102-
116+
103117
- name: Docker meta
104118
id: meta
105119
uses: docker/metadata-action@v5
106120
with:
107-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
121+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }}
108122
tags: |
109123
type=raw,value=latest,enable={{is_default_branch}}
110124
type=sha,prefix={{branch}}-,format=short
111125
type=sha,prefix={{branch}}-,format=long
112126
type=ref,event=pr
113127
type=ref,event=tag
114-
128+
115129
- name: Log in to Container Registry
116130
uses: docker/login-action@v3
117131
with:
118132
registry: ${{ env.REGISTRY }}
119133
username: ${{ github.actor }}
120134
password: ${{ secrets.GITHUB_TOKEN }}
121-
135+
122136
- name: Create manifest list and push
123137
working-directory: /tmp/digests
124138
run: |
125139
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
126-
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
127-
140+
$(printf '${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }}@sha256:%s ' *)
141+
128142
- name: Inspect image
129143
run: |
130-
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
144+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ steps.meta.outputs.version }}
131145

Justfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
devcontainer-validate:
33
npx --yes @devcontainers/cli read-configuration --workspace-folder .
44

5-
# Build devenv image with local tag
6-
devenv-build:
7-
cd devenv && podman build --jobs=4 -t localhost/bootc-devenv-debian .
5+
# Build devenv Debian image with local tag
6+
devenv-build-debian:
7+
cd devenv && podman build --jobs=4 -f Containerfile.debian -t localhost/bootc-devenv-debian .
8+
9+
# Build devenv CentOS Stream 10 image with local tag
10+
devenv-build-c10s:
11+
cd devenv && podman build --jobs=4 -f Containerfile.c10s -t localhost/bootc-devenv-c10s .
12+
13+
# Build devenv image with local tag (defaults to Debian)
14+
devenv-build: devenv-build-debian

devenv/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
*
55
# And explicit includes
66
!packages.txt
7+
!packages-common.txt
8+
!packages-debian.txt
9+
!packages-c10s.txt
710
!build-deps.txt
11+
!build-deps-debian.txt
12+
!build-deps-c10s.txt
813
!devenv-init.sh

devenv/Containerfile.c10s

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# These aren't packages, just low-dependency binaries dropped in /usr/local/bin
2+
# so we can fetch them independently in a separate build.
3+
ARG base=quay.io/centos/centos:stream10
4+
FROM $base as base
5+
# Life is too short to care about dash
6+
RUN ln -sfr /bin/bash /bin/sh
7+
RUN <<EORUN
8+
set -xeuo pipefail
9+
10+
# Initialize basic packages and enable repositories
11+
dnf -y install curl time bzip2 dnf-plugins-core epel-release
12+
dnf config-manager --set-enabled crb
13+
14+
# Enable gh CLI repository
15+
cat > /etc/yum.repos.d/gh-cli.repo <<'EOREPO'
16+
[gh-cli]
17+
name=GitHub CLI
18+
baseurl=https://cli.github.com/packages/rpm
19+
enabled=1
20+
gpgcheck=1
21+
gpgkey=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x23F3D4EA75716059
22+
EOREPO
23+
24+
# Update after adding repositories
25+
dnf -y makecache
26+
EORUN
27+
28+
FROM base as tools
29+
# renovate: datasource=github-releases depName=block/goose
30+
ARG gooseversion=v1.11.1
31+
# renovate: datasource=github-releases depName=bootc-dev/bcvk
32+
ARG bcvkversion=v0.5.3
33+
RUN <<EORUN
34+
set -xeuo pipefail
35+
arch=$(arch)
36+
37+
rm -vrf /usr/local/bin/*
38+
39+
# goose for local AI
40+
target=goose-${arch}-unknown-linux-gnu.tar.bz2
41+
/bin/time -f '%E %C' curl -fLO https://github.com/block/goose/releases/download/$gooseversion/$target
42+
tar xvjf $target
43+
mv goose /usr/local/bin/goose
44+
45+
# bcvk
46+
if test "${arch}" = x86_64; then
47+
td=$(mktemp -d)
48+
(
49+
cd $td
50+
target=bcvk-${arch}-unknown-linux-gnu
51+
/bin/time -f '%E %C' curl -fLO https://github.com/bootc-dev/bcvk/releases/download/$bcvkversion/${target}.tar.gz
52+
tar xvzf $target.tar.gz
53+
mv $target /usr/local/bin/bcvk
54+
)
55+
rm -rf $td
56+
else
57+
echo bcvk unavailable for $arch
58+
fi
59+
EORUN
60+
61+
FROM base as rust
62+
RUN <<EORUN
63+
set -xeuo pipefail
64+
# Setup rust; the idea here though is we install system-wide into /usr/local
65+
# as if it was packaged.
66+
export RUSTUP_HOME=/usr/local/rustup
67+
export CARGO_HOME=/usr/local/cargo
68+
# Install Rust system-wide
69+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default
70+
# Move binaries to /usr/local/bin (system-managed, root-owned)
71+
mv /usr/local/cargo/bin/* /usr/local/bin/
72+
# Nothing really left here
73+
rm -vrf /usr/local/cargo/bin
74+
EORUN
75+
76+
# This builds the image.
77+
# Build this using `just devenv-build-c10s` from the root of the repository.
78+
FROM base
79+
COPY packages-common.txt packages-c10s.txt build-deps-c10s.txt /run/src/
80+
WORKDIR /run/src
81+
RUN <<EORUN
82+
set -xeuo pipefail
83+
grep -hEve '^#' packages-common.txt packages-c10s.txt | /bin/time -f '%E %C' xargs dnf -y install
84+
grep -vEe '^#' build-deps-c10s.txt | /bin/time -f '%E %C' xargs dnf -y builddep
85+
dnf clean all
86+
EORUN
87+
88+
# Copy in the binaries from our tools container image
89+
COPY --from=tools /usr/local/bin/* /usr/local/bin/
90+
COPY --from=rust /usr/local/bin/* /usr/local/bin/
91+
COPY --from=rust /usr/local/rustup /usr/local/rustup
92+
# Point rustup at the system-wide installation, but let CARGO_HOME default to ~/.cargo
93+
ENV RUSTUP_HOME=/usr/local/rustup
94+
# Setup for codespaces
95+
COPY devenv-init.sh /usr/local/bin/
96+
97+
WORKDIR /
98+
# Create user before declaring volumes so home directory has correct ownership
99+
RUN <<EORUN
100+
set -xeuo pipefail
101+
useradd -m devenv -s /bin/bash
102+
# This needs to be precreated and owned by the devenv user
103+
mkdir -p ~devenv/.local/share/containers
104+
chown -R -h devenv: ~devenv/.local
105+
echo 'devenv ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/devenv && chmod 0440 /etc/sudoers.d/devenv
106+
EORUN
107+
# To avoid overlay-on-overlay with nested containers
108+
VOLUME [ "/var/lib/containers", "/home/devenv/.local/share/containers/" ]
109+
USER devenv

devenv/Containerfile.debian

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# These aren't packages, just low-dependency binaries dropped in /usr/local/bin
2+
# so we can fetch them independently in a separate build.
3+
ARG base=docker.io/library/debian:sid
4+
FROM $base as base
5+
# Life is too short to care about dash
6+
RUN ln -sfr /bin/bash /bin/sh
7+
RUN <<EORUN
8+
set -xeuo pipefail
9+
10+
# Initialize some basic packages
11+
apt -y update && apt -y install curl time bzip2
12+
13+
# Enable deb-src repositories for build-dep
14+
sed -i "s/^deb /deb [arch=$(dpkg --print-architecture)] /" /etc/apt/sources.list.d/debian.sources
15+
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources
16+
17+
# Enable gh CLI repository
18+
mkdir -p -m 755 /etc/apt/keyrings
19+
curl -fLo /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg
20+
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
21+
mkdir -p -m 755 /etc/apt/sources.list.d
22+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list
23+
24+
# And re-update after we've fetched repos
25+
apt -y update
26+
EORUN
27+
28+
FROM base as tools
29+
# renovate: datasource=github-releases depName=block/goose
30+
ARG gooseversion=v1.11.1
31+
# renovate: datasource=github-releases depName=bootc-dev/bcvk
32+
ARG bcvkversion=v0.5.3
33+
RUN <<EORUN
34+
set -xeuo pipefail
35+
arch=$(arch)
36+
37+
rm -vrf /usr/local/bin/*
38+
39+
# goose for local AI
40+
target=goose-${arch}-unknown-linux-gnu.tar.bz2
41+
/bin/time -f '%E %C' curl -fLO https://github.com/block/goose/releases/download/$gooseversion/$target
42+
tar xvjf $target
43+
mv goose /usr/local/bin/goose
44+
45+
# bcvk
46+
if test "${arch}" = x86_64; then
47+
td=$(mktemp -d)
48+
(
49+
cd $td
50+
target=bcvk-${arch}-unknown-linux-gnu
51+
/bin/time -f '%E %C' curl -fLO https://github.com/bootc-dev/bcvk/releases/download/$bcvkversion/${target}.tar.gz
52+
tar xvzf $target.tar.gz
53+
mv $target /usr/local/bin/bcvk
54+
)
55+
rm -rf $td
56+
else
57+
echo bcvk unavailable for $arch
58+
fi
59+
EORUN
60+
61+
FROM base as rust
62+
RUN <<EORUN
63+
set -xeuo pipefail
64+
# Setup rust; the idea here though is we install system-wide into /usr/local
65+
# as if it was packaged.
66+
export RUSTUP_HOME=/usr/local/rustup
67+
export CARGO_HOME=/usr/local/cargo
68+
# Install Rust system-wide
69+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default
70+
# Move binaries to /usr/local/bin (system-managed, root-owned)
71+
mv /usr/local/cargo/bin/* /usr/local/bin/
72+
# Nothing really left here
73+
rm -vrf /usr/local/cargo/bin
74+
EORUN
75+
76+
# This builds the image.
77+
# Build this using `just devenv-build-debian` from the root of the repository.
78+
FROM base
79+
COPY packages-common.txt packages-debian.txt build-deps-debian.txt /run/src/
80+
WORKDIR /run/src
81+
RUN <<EORUN
82+
set -xeuo pipefail
83+
grep -hEve '^#' packages-common.txt packages-debian.txt | /bin/time -f '%E %C' xargs apt -y install
84+
grep -vEe '^#' build-deps-debian.txt | /bin/time -f '%E %C' xargs apt -y build-dep
85+
apt clean && rm -rf /var/lib/apt/lists/*
86+
EORUN
87+
88+
# Copy in the binaries from our tools container image
89+
COPY --from=tools /usr/local/bin/* /usr/local/bin/
90+
COPY --from=rust /usr/local/bin/* /usr/local/bin/
91+
COPY --from=rust /usr/local/rustup /usr/local/rustup
92+
# Point rustup at the system-wide installation, but let CARGO_HOME default to ~/.cargo
93+
ENV RUSTUP_HOME=/usr/local/rustup
94+
# Setup for codespaces
95+
COPY devenv-init.sh /usr/local/bin/
96+
97+
WORKDIR /
98+
# Create user before declaring volumes so home directory has correct ownership
99+
RUN <<EORUN
100+
set -xeuo pipefail
101+
useradd -m devenv -s /bin/bash
102+
# This needs to be precreated and owned by the devenv user
103+
mkdir -p ~devenv/.local/share/containers
104+
chown -R -h devenv: ~devenv/.local
105+
echo 'devenv ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/devenv && chmod 0440 /etc/sudoers.d/devenv
106+
EORUN
107+
# To avoid overlay-on-overlay with nested containers
108+
VOLUME [ "/var/lib/containers", "/home/devenv/.local/share/containers/" ]
109+
USER devenv

devenv/build-deps-c10s.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ostree

devenv/build-deps-debian.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ostree

devenv/packages-c10s.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CentOS Stream 10 specific package names
2+
# Common packages are in packages-common.txt
3+
4+
# General build env
5+
clang-tools-extra
6+
krb5-devel
7+
libvirt-devel
8+
ostree-devel
9+
10+
# Runtime virt
11+
xorriso
12+
qemu-img
13+
libvirt-daemon-kvm
14+
15+
# TUI editors
16+
vim-enhanced

0 commit comments

Comments
 (0)