Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/prek_checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: prek checks
# push is not included because build workflows call this on push
on: [pull_request, workflow_call, workflow_dispatch]
on: [workflow_call, workflow_dispatch]

jobs:
prek:
Expand All @@ -21,6 +20,9 @@ jobs:
env:
# The first three variables (HADOLINT_DOWNLOAD, HADOLINT_BINARY,
# HADOLINT_VERSION) are all parts of the release binary URL.
#
# The first two variables are generic and shouldn't need to be
# updated
HADOLINT_DOWNLOAD: >-
https://github.com/hadolint/hadolint/releases/download
HADOLINT_BINARY: hadolint-linux-x86_64
Expand All @@ -47,6 +49,7 @@ jobs:
with:
install-only: true


# The no-commit-to-branch builtin hook is skipped to avoid false
# positives (ex. when PRs are merged)
- name: 'Run prek'
Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/trixie-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
# https://docs.github.com/en/actions/reference/workflows-and-actions/variables
name: 'trixie-dev'
# GHCR: GitHub Container Registry

on:
pull_request:
branches-ignore: [main]
paths:
- '.github/workflows/trixie-dev.yml'
- '.github/workflows/prek_checks.yml'
- 'trixie/'
- '!trixie/README.md'
workflow_dispatch:

env:
DESCRIPTION: 'Creative Commons (CC) Debian 13 (trixie) development'
OCI: 'org.opencontainers.image'
TITLE: 'CC Debian trixie (development)'
URL: 'https://github.com/creativecommons/containers/trixie'
VENDOR: 'Creative Commons'

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:

prek_checks:
uses: $/.github/workflows/prek_checks.yml

build_and_push:
needs: prek_checks
permissions:
contents: read
packages: write
runs-on: ubuntu-latest

steps:

- parallel:

# https://github.com/docker/login-action
- name: Docker login to GitHub Container Registry (GHCR)
# docker/login-action v4.8.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/metadata-action
- name: Docker extract metadata
id: docker_meta
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
# docker/metadata-action v6.2.0
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302
with:
annotations: |
${{ env.OCI }}.created={{ date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]' }}
${{ env.OCI }}.description=${{ env.DESCRIPTION }}
${{ env.OCI }}.source=${{ env.URL }}
${{ env.OCI }}.title=${{ env.TITLE }}
${{ env.OCI }}.url=${{ env.URL }}
${{ env.OCI }}.vendor=${{ env.VENDOR }}
images: ghcr.io/creativecommons/trixie-dev
# https://specs.opencontainers.org/image-spec/annotations/
labels: |
${{ env.OCI }}.created={{ date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]' }}
${{ env.OCI }}.description=${{ env.DESCRIPTION }}
${{ env.OCI }}.source=${{ env.URL }}
${{ env.OCI }}.title=${{ env.TITLE }}
${{ env.OCI }}.url=${{ env.URL }}
${{ env.OCI }}.vendor=${{ env.VENDOR }}
tags: |
type=ref,event=pr,suffix=-{{ sha }}

# https://github.com/docker/setup-buildx-action
- name: Docker setup Buildx
id: docker_buildx
# docker/setup-buildx-action v4.4.1
uses: >-
docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069
with:
platforms: linux/amd64,linux/arm64

# https://github.com/actions/checkout
- name: GitHub checkout repository
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1


# https://github.com/docker/build-push-action
- name: Build and push Docker trixie image to GHCR
# build-push-action v7.4.0
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc
with:
annotations: ${{ steps.docker_meta.outputs.annotations }}
builder: ${{ steps.docker_buildx.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: trixie
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: ${{ steps.docker_buildx.outputs.platforms }}
provenance: false
push: true
sbom: false
tags: ${{ steps.docker_meta.outputs.tags }}
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
# https://docs.github.com/en/actions/reference/workflows-and-actions/variables
name: Build & push trixie to GHCR
name: 'trixie'
# GHCR: GitHub Container Registry

on:
create:
push:
branches: [main]
paths:
- '.github/workflows/build_trixie_to_ghcr.yml'
- '.github/workflows/trixie.yml'
- '.github/workflows/prek_checks.yml'
- 'trixie/'
- '!trixie/README.md'
workflow_dispatch:

env:
DESCRIPTION: 'Creative Commons (CC) Debian 13 (trixe)'
DESCRIPTION: 'Creative Commons (CC) Debian 13 (trixie)'
OCI: 'org.opencontainers.image'
TITLE: 'CC Debian trixie'
TYPE_RAW__DEFAULT_ONLY__VALUE_DATE: >-
type=raw,enable={{is_default_branch}},value={{date 'YYYYMMDD-HHmmss'}}
URL: 'https://github.com/creativecommons/base-containers/trixie'
URL: 'https://github.com/creativecommons/containers/trixie'
VENDOR: 'Creative Commons'

jobs:
Expand Down Expand Up @@ -72,9 +70,8 @@ jobs:
${{ env.OCI }}.url=${{ env.URL }}
${{ env.OCI }}.vendor=${{ env.VENDOR }}
tags: |
${{ env.TYPE_RAW__DEFAULT_ONLY__VALUE_DATE }}
type=raw,enable={{ is_default_branch }},priority=100,value=latest
type=sha,enable={{ is_not_default_branch }},prefix={{ branch }}-
type=raw,value={{date 'YYYYMMDD-HHmmss'}}
type=raw,priority=100,value=latest

# https://github.com/docker/setup-buildx-action
- name: Docker setup Buildx
Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ services:
build:
context: trixie
# disable the entrypoint as the image is only being built locally for use
# by trixie-dev
# by other services
entrypoint: /bin/true
image: trixie

# Development overlay
trixie-dev:
# Local development overlay
trixie-local:
build:
additional_contexts:
trixie: "service:trixie"
context: trixie-dev
context: trixie-local
command: sh -c 'echo "CMD ignored? (this should NOT show up in console)"'
env_file: .env
image: trixie-local
18 changes: 8 additions & 10 deletions trixie-dev/Dockerfile → trixie-local/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@
FROM trixie

# https://docs.docker.com/build/building/best-practices/#apt-get
# - Resynchronize the package index, update packages, install packages,
# and clean-up apt/dpkg
# - apt and dpkg are configured in parent CC Debian trixie image
# - Retrieve new lists of packages, distribution upgrade, install new
# packages, erase downloaded archive files, and erase package lists
RUN set -o errexit -o nounset \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
--no-allow-insecure-repositories --quiet \
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade \
--no-install-recommends --no-install-suggests --quiet --yes \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends --no-install-suggests --quiet --yes \
&& apt-get update --quiet \
&& apt-get dist-upgrade --quiet --yes \
&& apt-get install --quiet --yes \
curl \
httpie \
less \
ripgrep \
tree \
vim \
wget \
&& DEBIAN_FRONTEND=noninteractive apt-get clean --quiet
&& apt-get clean --quiet \
&& rm --recursive --force /var/lib/apt/lists/*

# Create a Sleep service
COPY --chmod=0555 sleep-run /etc/sv/sleep/run

RUN set -o errexit -o nounset \
&& mkdir --parents /etc/sv/sleep/log \
&& ln -s /etc/sv/socklog-unix/log/run /etc/sv/sleep/log/run \
Expand Down
2 changes: 1 addition & 1 deletion trixie-dev/sleep-run → trixie-local/sleep-run
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ sv start socklog-unix >/dev/null \
&& sv check socklog-unix >/dev/null \
|| exit 170
exec 2>&1
echo 'Sleeping 💤'
printf '\e[34mSleeping\e[0m 💤\n'
exec sleep 60
37 changes: 23 additions & 14 deletions trixie/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,44 @@ FROM debian:trixie-slim
COPY dpkg-cfg-socklog-slim /etc/dpkg/dpkg.cfg.d/socklog-slim

# https://docs.docker.com/build/building/best-practices/#apt-get
# - Resynchronize the package index, update packages, install packages,
# clean-up apt/dpkg, and update CA certificates
# 1. Configure apt to avoid optional packages
# 2. Configure debconf to use noninteractive frontend
# 3. Retrieve new lists of packages, distribution upgrade, install new
# packages, erase downloaded archive files, erase package lists, and update
# certificate authority certificates
COPY docker-slim /etc/apt/apt.conf.d/docker-slim
RUN set -o errexit -o nounset \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
--no-allow-insecure-repositories --quiet \
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade \
--no-install-recommends --no-install-suggests --quiet --yes \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
--no-install-recommends --no-install-suggests --quiet --yes \
sed --regexp-extended --in-place \
-e's/^(Templates:.+)$/\1\n# Debconf will select the default answer/' \
-e's/(default answer)$/\1\nFrontend: noninteractive/' \
/etc/debconf.conf \
&& apt-get update --quiet \
&& apt-get dist-upgrade --quiet --yes \
&& apt-get install --quiet --yes \
dumb-init \
ca-certificates \
msmtp-mta \
runit \
socklog-run \
&& DEBIAN_FRONTEND=noninteractive apt-get clean --quiet \
&& apt-get clean --quiet \
&& rm --recursive --force /var/lib/apt/lists/* \
&& update-ca-certificates

# Runit configuration
#
# The default-syslog service is handled specially by runit (packages has
# related triggers). It can't be excluded and must be added before it can be
# removed.
# - The default-syslog service is handled specially by runit (packages has
# related triggers). It can't be excluded and must be added before it can be
# removed.
COPY --chmod=0555 log-run /etc/sv/socklog-unix/log/run
RUN set -o errexit -o nounset \
&& update-service --add socklog-unix \
&& update-service --add default-syslog \
&& update-service --remove default-syslog
COPY --parents conf.d/* color_vars.sh /etc/container/
COPY --chmod=0555 setup.sh /etc/container/
ENTRYPOINT ["/usr/bin/dumb-init", "/etc/container/setup.sh"]

# Initialization
# 1. dumb-init is a signal repeater that defaults to process group mode
# 2. setup script sources any available configuration scripts
# 3. setup execs runit's runsvdir service management
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/etc/container/setup.sh"]
# ⚠️ NOTE: CMD is ignored. Services must be installed and enabled per runit.
8 changes: 5 additions & 3 deletions trixie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ When the image starts up, the `/etc/container/setup.sh`
## Deployment

The image is deployed via GitHub Actions to the GitHub Container Registry
(GHCR). See the workflow for details:
[`../.github/workflows/build_trixie_to_ghcr.yml`][build].
(GHCR). See the workflows for details:
- `main` branch: [`../.github/workflows/trixie.yml`][build]
- all other branches: [`../.github/workflows/trixie-dev.yml`][build-dev]

[build]: ../.github/workflows/build_trixie_to_ghcr.yml
[build]: ../.github/workflows/trixi.yml
[build]: ../.github/workflows/trixie-dev.yml


## Extending
Expand Down
8 changes: 8 additions & 0 deletions trixie/docker-slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://www.debian.org/doc/manuals/aptitude/ch02s05s05.en.html#configAptInstall-Recommends
# https://manpages.debian.org/trixie/apt/apt-get.8.en.html#OPTIONS
APT::Install-Recommends "false";

# https://manpages.debian.org/trixie/apt/apt-get.8.en.html#OPTIONS
APT::Install-Suggests "false";

# vim: filetype=aptconf
2 changes: 1 addition & 1 deletion trixie/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ do
. "${_config_script}"
done

# Prep and execute runit
# Prep and execute runit service management
# Based on /etc/runit/2
mkdir --parents /run/runit/supervise
/lib/runit/trigger_sv setup
Expand Down
Loading