Skip to content

Commit

Permalink
ref: Create separate kernel and module images
Browse files Browse the repository at this point in the history
This commit moves the kernel image out of the flintlock/ subdir and
splits the kernel image into two: one containing just the binary, the
other just the module.

The sequence works like so:
- `builder` creates a starting point image from Ubuntu, installing
  packages etc.
- `base` uses builder, pulls and compiles the kernel, then saves the
  modules and the binary in a `scratch` image. I have kept this image
  under the old `flintlock-kernel` name with modules and the binary to
  maintain backwards compatibility.
- `modules` and `bin` use `base` and simply copy the things they need
  into a `scratch` image.

The images produced are:
- `kernel-builder`
- `flintlock-kernel` (kept the same for backwards compatibility)
- `kernel-bin`
- `kernel-modules`
  • Loading branch information
Callisto13 committed Dec 19, 2022
1 parent 942142c commit 4baec80
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 39 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/flintlock-ubuntu-perftest.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Ubuntu Perf Test - Build and release

on:
pull_request:
paths:
- 'flintlock/perf-test/**'
branches: [main]
push:
paths:
- 'flintlock/perf-test/**'
branches: [main]
on: {}
# pull_request:
# paths:
# - 'flintlock/perf-test/**'
# branches: [main]
# push:
# paths:
# - 'flintlock/perf-test/**'
# branches: [main]

defaults:
run:
Expand Down Expand Up @@ -41,4 +41,4 @@ jobs:
- name: Build and push
run: |
make
make push
make push
5 changes: 3 additions & 2 deletions .github/workflows/kernel-images-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

defaults:
run:
working-directory: flintlock/kernel
working-directory: kernel

jobs:
release:
Expand All @@ -30,5 +30,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: |
make builder
make
make push
make push
13 changes: 8 additions & 5 deletions .github/workflows/kernel-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: Kernel - Build and release
on:
pull_request:
paths:
- 'flintlock/kernel/**'
- 'kernel/**'
branches: [main]
push:
paths:
- 'flintlock/kernel/**'
- 'kernel/**'
branches: [main]

defaults:
run:
working-directory: flintlock/kernel
working-directory: kernel

jobs:
build:
Expand All @@ -27,7 +27,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build kernel
run: make
run: |
make builder
make
release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
Expand All @@ -50,5 +52,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: |
make builder
make
make push
make push
22 changes: 0 additions & 22 deletions flintlock/kernel/Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions kernel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
DOCKER := docker

REGISTRY?=ghcr.io/weaveworks-liquidmetal

BUILDER_IMAGE_NAME?=kernel-builder
BASE_IMAGE_NAME?=flintlock-kernel
BIN_IMAGE_NAME?=kernel-bin
MOD_IMAGE_NAME?=kernel-modules

KERNEL_VERSIONS ?= 4.19.215 5.10.77 # If you update this list, please remember to update the matrix in the kernel-images.yml github action!

all: build

builder:
$(DOCKER) build -t $(BUILDER_IMAGE_NAME):dev \
-f builder/Dockerfile .

build: $(addprefix build-,$(KERNEL_VERSIONS))
build-%: builder
$(MAKE) base-$*
$(MAKE) binary-$*
$(MAKE) modules-$*
base-%:
$(DOCKER) build -t $(BASE_IMAGE_NAME):$* \
--build-arg KERNEL_VERSION=$* \
--build-arg IMAGE_NAME=$(BUILDER_IMAGE_NAME) \
-f base/Dockerfile .
binary-%:
$(DOCKER) build -t $(BIN_IMAGE_NAME):$* \
--build-arg IMAGE_NAME=$(BASE_IMAGE_NAME):$* \
-f bin/Dockerfile .
modules-%:
$(DOCKER) build -t $(MOD_IMAGE_NAME):$* \
--build-arg IMAGE_NAME=$(BASE_IMAGE_NAME):$* \
-f modules/Dockerfile .

push: $(addprefix push-,$(KERNEL_VERSIONS))
push-%:
$(DOCKER) push $(REGISTRY)/$(BASE_IMAGE_NAME):$*
$(DOCKER) push $(REGISTRY)/$(BIN_IMAGE_NAME):$*
$(DOCKER) push $(REGISTRY)/$(MOD_IMAGE_NAME):$*
Empty file added kernel/README.md
Empty file.
File renamed without changes.
5 changes: 5 additions & 0 deletions kernel/bin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG IMAGE_NAME
FROM ${IMAGE_NAME} AS builder
FROM scratch

COPY --from=builder /boot /boot
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions kernel/modules/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG IMAGE_NAME
FROM ${IMAGE_NAME} AS builder
FROM scratch

COPY --from=builder /lib/modules /lib/modules

0 comments on commit 4baec80

Please sign in to comment.