Skip to content

Commit a96d334

Browse files
authored
feat(devcontainer-base): Create a new base image for devcontainers (#747)
A fedora-based image that we can use in various repos, including this one. I'm not yet migrating ours...this needs to publish via the workflow first. No tags here; we'll just depend on pinning.
1 parent 1d243e9 commit a96d334

7 files changed

Lines changed: 135 additions & 1 deletion

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Build Devcontainer Base Image
3+
4+
on: # yamllint disable-line rule:truthy
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- .github/workflows/image-devcontainer-base.yml
10+
- images/devcontainer-base/**
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- .github/workflows/image-devcontainer-base.yml
16+
- images/devcontainer-base/**
17+
schedule:
18+
- cron: '0 0 * * 0' # Triggers every Sunday at midnight UTC
19+
20+
jobs:
21+
build-container:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout Repo
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
- name: Login to GitHub Container Registry
31+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Generate Metadata
37+
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
38+
id: metadata
39+
with:
40+
images: ghcr.io/${{ github.repository_owner }}/devcontainer-base
41+
- name: Build Image
42+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
43+
with:
44+
context: images/devcontainer-base
45+
file: images/devcontainer-base/Containerfile
46+
push: ${{ github.event_name != 'pull_request' }}
47+
tags: ghcr.io/${{ github.repository_owner }}/devcontainer-base:latest
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG USERNAME=vscode
2+
ARG USERID=1000
3+
ARG GROUPID=1000
4+
5+
FROM scratch AS ctx
6+
COPY build_files /
7+
8+
FROM quay.io/fedora/fedora-minimal:44
9+
10+
RUN --mount=type=bind,from=ctx,source=/,target=/ctx \
11+
--mount=type=cache,dst=/var/cache \
12+
--mount=type=cache,dst=/var/log \
13+
--mount=type=tmpfs,dst=/tmp \
14+
/ctx/build.sh
15+
16+
WORKDIR /home/${USERNAME}
17+
USER ${USERNAME}

images/devcontainer-base/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Marinated Concrete's Fedora-Based Devcontainer Image
2+
3+
This is a Fedora-based devcontainer base image that can be used for more
4+
specific devcontainers. The goal is to provide a small, minimal devcontainer
5+
image that works well with vscode.
6+
7+
We automatically publish a new version weekly, or when relevant changes are made.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -ouex pipefail
4+
5+
/ctx/packages.sh
6+
7+
# Cleanup
8+
dnf clean all
9+
rm -rf /var/lib/dnf
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -eoux pipefail
4+
5+
# The set of packages that are needed for this build to work.
6+
CORE_PACKAGES=(
7+
"curl"
8+
"gzip"
9+
"tar"
10+
)
11+
12+
# The set of packages that we agree are too useful to not have in the base
13+
# image.
14+
COMMON_PACKAGES=(
15+
# It's never DNS, but it's good to verify that...
16+
"bind-utils"
17+
"iproute"
18+
"iputils"
19+
# These are core utilities that seem silly to not include.
20+
"coreutils"
21+
"sudo"
22+
"watch"
23+
# Source Control
24+
"diffutils"
25+
"git"
26+
# Editor of choice.
27+
"vim"
28+
)
29+
30+
dnf upgrade -y
31+
dnf install \
32+
--setopt=install_weak_deps=False \
33+
-y \
34+
"${CORE_PACKAGES[@]}" \
35+
"${COMMON_PACKAGES[@]}"
36+
37+
# Now we can invoke some additional scripts for potentially more complicated installs.
38+
/ctx/packages/just.sh
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -eoux pipefail
4+
5+
# Just is so common and useful in our devcontainers, that we actually set it
6+
# up in the base image.
7+
8+
# renovate: datasource=github-releases depName=casey/just
9+
JUST_VERSION=1.51.0
10+
curl \
11+
-s \
12+
-L \
13+
https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-x86_64-unknown-linux-musl.tar.gz | \
14+
tar -xvzf - -C /tmp
15+
mv /tmp/just /usr/local/bin/just

renovate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"pinDigest"
2020
],
2121
"matchPackageNames": [
22-
"fedora"
22+
"fedora",
23+
"fedora-minimal"
2324
]
2425
},
2526
{

0 commit comments

Comments
 (0)