Skip to content

Commit f91f98c

Browse files
feat(docker): Add container image containing the CLP package, for Docker Compose integration (resolves #1164). (#1166)
Co-authored-by: kirkrodrigues <[email protected]>
1 parent 0de99a9 commit f91f98c

File tree

15 files changed

+196
-54
lines changed

15 files changed

+196
-54
lines changed

.github/actions/clp-execution-image-build/action.yaml renamed to .github/actions/clp-build-runtime-image/action.yaml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: "clp-execution-image-build"
2-
description: "Builds a container image that contains the dependencies necessary
3-
to run the CLP package."
1+
name: "clp-build-runtime-image"
2+
description: "Builds a container image to be used for running CLP."
43

54
inputs:
5+
image_type:
6+
description: "Type of image to build"
7+
required: true
68
image_registry:
79
default: "ghcr.io"
810
description: "Container image registry"
@@ -17,11 +19,11 @@ inputs:
1719
required: false
1820
platform_id:
1921
description: "Platform ID of the container (e.g. ubuntu)"
20-
required: true
22+
required: false
2123
platform_version_id:
2224
description: "Platform VERSION_ID / VERSION_CODENAME of the container
2325
(e.g. jammy, focal, etc.)"
24-
required: true
26+
required: false
2527

2628
runs:
2729
using: "composite"
@@ -45,20 +47,37 @@ runs:
4547
echo "REPOSITORY=$(echo '${{github.repository}}' | tr '[:upper:]' '[:lower:]')" \
4648
>> "$GITHUB_OUTPUT"
4749
48-
- name: "Update Metadata"
49-
id: "meta"
50+
- name: "Compute metadata"
51+
id: "compute-meta"
52+
shell: "bash"
53+
run: |
54+
base_path="./tools/docker-images"
55+
56+
if [[ "${{inputs.image_type}}" == "execution" ]]; then
57+
platform="${{inputs.platform_id}}-${{inputs.platform_version_id}}"
58+
dockerfile_path="$base_path/clp-execution-base-$platform/Dockerfile"
59+
image_name="clp-${{inputs.image_type}}-$platform"
60+
else
61+
dockerfile_path="$base_path/clp-package/Dockerfile"
62+
image_name="clp-${{inputs.image_type}}"
63+
fi
64+
65+
echo "DOCKERFILE=$dockerfile_path" >> "$GITHUB_OUTPUT"
66+
echo "IMAGE_NAME=$image_name" >> "$GITHUB_OUTPUT"
67+
68+
- name: "Extract GitHub Metadata"
69+
id: "extract-gh-meta"
5070
uses: "docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804"
5171
with:
5272
images: "${{inputs.image_registry}}/${{steps.sanitization.outputs.REPOSITORY}}\
53-
/clp-execution-x86-${{inputs.platform_id}}-${{inputs.platform_version_id}}"
73+
/${{steps.compute-meta.outputs.IMAGE_NAME}}"
5474

5575
- name: "Build and Push"
5676
if: "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'"
5777
uses: "docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4"
5878
with:
5979
context: "./"
60-
file: "./tools/docker-images/\
61-
clp-execution-base-${{inputs.platform_id}}-${{inputs.platform_version_id}}/Dockerfile"
80+
file: "${{steps.compute-meta.outputs.DOCKERFILE}}"
6281
push: true
63-
tags: "${{steps.meta.outputs.tags}}"
64-
labels: "${{steps.meta.outputs.labels}}"
82+
tags: "${{steps.extract-gh-meta.outputs.tags}}"
83+
labels: "${{steps.extract-gh-meta.outputs.labels}}"

.github/actions/run-on-image/action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ runs:
4242
- run: "./tools/scripts/deps-download/init.sh"
4343
shell: "bash"
4444

45+
# `--env npm_config_cache` overrides the default `/.npm` to avoid permission issues.
4546
- run: >-
4647
docker run
4748
--user $(id -u):$(id -g)
49+
--env npm_config_cache=/tmp/.npm
4850
--volume "$GITHUB_WORKSPACE":/mnt/repo
4951
--workdir /mnt/repo
5052
${{steps.get_image_props.outputs.qualified_image_name}}

.github/workflows/clp-core-build.yaml renamed to .github/workflows/clp-artifact-build.yaml

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1-
name: "clp-core-build"
1+
name: "clp-artifact-build"
22

33
on:
44
pull_request:
5-
paths:
6-
- ".github/actions/clp-core-build-containers/action.yaml"
7-
- ".github/actions/run-on-image/action.yaml"
8-
- ".github/workflows/clp-core-build.yaml"
9-
- ".gitmodules"
10-
- "components/core/**"
11-
- "taskfile.yaml"
12-
- "taskfiles/**"
13-
- "tools/scripts/deps-download/**"
14-
- "!components/core/tools/scripts/lib_install/macos/**"
5+
paths-ignore: &ignored_paths
6+
- ".github/*"
7+
- ".github/ISSUE_TEMPLATE/**"
8+
- "components/core/tools/scripts/lib_install/macos/**"
9+
- "docs/**"
1510
push:
16-
paths:
17-
- ".github/actions/clp-core-build-containers/action.yaml"
18-
- ".github/actions/run-on-image/action.yaml"
19-
- ".github/workflows/clp-core-build.yaml"
20-
- ".gitmodules"
21-
- "components/core/**"
22-
- "taskfile.yaml"
23-
- "taskfiles/**"
24-
- "tools/scripts/deps-download/**"
25-
- "!components/core/tools/scripts/lib_install/macos/**"
11+
paths-ignore: *ignored_paths
2612
schedule:
2713
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
2814
- cron: "15 0 * * *"
@@ -74,31 +60,31 @@ jobs:
7460
filters: |
7561
centos_stream_9_image:
7662
- ".github/actions/**"
77-
- ".github/workflows/clp-core-build.yaml"
63+
- ".github/workflows/clp-artifact-build.yaml"
7864
- "components/core/tools/scripts/lib_install/*.sh"
7965
- "components/core/tools/docker-images/clp-env-base-centos-stream-9/**"
8066
- "components/core/tools/scripts/lib_install/centos-stream-9/**"
8167
manylinux_2_28_x86_64_image:
8268
- ".github/actions/**"
83-
- ".github/workflows/clp-core-build.yaml"
69+
- ".github/workflows/clp-artifact-build.yaml"
8470
- "components/core/tools/scripts/lib_install/*.sh"
8571
- "components/core/tools/docker-images/clp-env-base-manylinux_2_28-x86_64/**"
8672
- "components/core/tools/scripts/lib_install/manylinux_2_28/**"
8773
musllinux_1_2_x86_64_image:
8874
- ".github/actions/**"
89-
- ".github/workflows/clp-core-build.yaml"
75+
- ".github/workflows/clp-artifact-build.yaml"
9076
- "components/core/tools/scripts/lib_install/*.sh"
9177
- "components/core/tools/docker-images/clp-env-base-musllinux_1_2-x86_64/**"
9278
- "components/core/tools/scripts/lib_install/musllinux_1_2/**"
9379
ubuntu_jammy_image:
9480
- ".github/actions/**"
95-
- ".github/workflows/clp-core-build.yaml"
81+
- ".github/workflows/clp-artifact-build.yaml"
9682
- "components/core/tools/scripts/lib_install/*.sh"
9783
- "components/core/tools/docker-images/clp-env-base-ubuntu-jammy/**"
9884
- "components/core/tools/scripts/lib_install/ubuntu-jammy/**"
9985
clp:
10086
- ".github/actions/**"
101-
- ".github/workflows/clp-core-build.yaml"
87+
- ".github/workflows/clp-artifact-build.yaml"
10288
- ".gitmodules"
10389
- "components/core/cmake/**"
10490
- "components/core/CMakeLists.txt"
@@ -520,3 +506,42 @@ jobs:
520506
.task/checksum/utils-cpp-lint-clang-tidy-*
521507
build/lint-clang-tidy
522508
key: "${{steps.cache-restore-lint-check-cpp-static-full.outputs.cache-primary-key}}"
509+
510+
package-image:
511+
name: "package-image"
512+
if: >-
513+
!cancelled() && !failure() && (
514+
needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'false' ||
515+
needs.ubuntu-jammy-deps-image.result == 'success'
516+
)
517+
needs:
518+
- "filter-relevant-changes"
519+
- "ubuntu-jammy-deps-image"
520+
runs-on: "ubuntu-24.04"
521+
steps:
522+
- uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
523+
with:
524+
submodules: "recursive"
525+
526+
- name: "Workaround actions/runner-images/issues/6775"
527+
shell: "bash"
528+
run: "chown $(id -u):$(id -g) -R ."
529+
530+
- name: "Build the package"
531+
uses: "./.github/actions/run-on-image"
532+
env:
533+
OS_NAME: "ubuntu-jammy"
534+
with:
535+
image_name: "${{env.DEPS_IMAGE_NAME_PREFIX}}${{env.OS_NAME}}"
536+
use_published_image: >-
537+
${{needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'false'
538+
|| (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')}}
539+
run_command: >-
540+
CLP_CORE_MAX_PARALLELISM_PER_BUILD_TASK=$(getconf _NPROCESSORS_ONLN) task package
541+
542+
- uses: "./.github/actions/clp-build-runtime-image"
543+
with:
544+
image_type: "package"
545+
image_registry: "ghcr.io"
546+
image_registry_username: "${{github.actor}}"
547+
image_registry_password: "${{secrets.GITHUB_TOKEN}}"

.github/workflows/clp-execution-image-build.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: "clp-execution-image-build"
33
on:
44
pull_request:
55
paths:
6-
- ".github/actions/clp-execution-image-build/action.yaml"
6+
- ".github/actions/clp-build-runtime-image/action.yaml"
77
- ".github/workflows/clp-execution-image-build.yaml"
88
- "tools/docker-images/**/*"
99
push:
1010
paths:
11-
- ".github/actions/clp-execution-image-build/action.yaml"
11+
- ".github/actions/clp-build-runtime-image/action.yaml"
1212
- ".github/workflows/clp-execution-image-build.yaml"
1313
- "tools/docker-images/**/*"
1414
schedule:
@@ -61,8 +61,9 @@ jobs:
6161
shell: "bash"
6262
run: "chown $(id -u):$(id -g) -R ."
6363

64-
- uses: "./.github/actions/clp-execution-image-build"
64+
- uses: "./.github/actions/clp-build-runtime-image"
6565
with:
66+
image_type: "execution"
6667
image_registry: "ghcr.io"
6768
image_registry_username: "${{github.actor}}"
6869
image_registry_password: "${{secrets.GITHUB_TOKEN}}"

components/core/tools/scripts/lib_install/ubuntu-jammy/install-prebuilt-packages.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
2323
openjdk-11-jdk \
2424
pkg-config \
2525
python3 \
26+
python3-dev \
2627
python3-pip \
2728
python3-venv \
29+
rsync \
2830
software-properties-common \
2931
unzip
3032

docs/src/dev-docs/building-package.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,15 @@ To clean up all build artifacts, run:
6868
task clean
6969
```
7070

71+
## Building a Docker image
72+
73+
To build a Docker image containing the CLP package, run:
74+
75+
```shell
76+
task docker-images:package
77+
```
78+
79+
This will create a Docker image named `clp-package:dev`.
80+
7181
[clp-issue-872]: https://github.com/y-scope/clp/issues/872
7282
[Task]: https://taskfile.dev/

docs/src/dev-docs/contributing-linting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Before submitting a PR, ensure you've run our linting tools and either fixed any violations or
44
suppressed the warning. If you can't run the linting workflows locally, you can enable and run the
5-
[clp-lint] and [clp-core-build] workflows in your fork.
5+
[clp-lint] and [clp-artifact-build] workflows in your fork.
66

77
## Requirements
88

@@ -32,7 +32,7 @@ To also apply any automatic fixes:
3232
task lint:fix
3333
```
3434

35-
[clp-core-build]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-core-build.yaml
35+
[clp-artifact-build]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-artifact-build.yaml
3636
[clp-lint]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-lint.yaml
3737
[clp-issue-872]: https://github.com/y-scope/clp/issues/872
3838
[feature-req]: https://github.com/y-scope/clp/issues/new?assignees=&labels=enhancement&projects=&template=feature-request.yml

docs/src/dev-docs/tooling-containers.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ environment.
147147
tools/docker-images/clp-execution-base-ubuntu-jammy
148148
```
149149

150+
## clp-package
151+
152+
An image containing the CLP package.
153+
154+
* Path:
155+
156+
```text
157+
tools/docker-images/clp-package
158+
```
159+
150160
[core-deps-centos-stream-9]: https://github.com/y-scope/clp/pkgs/container/clp%2Fclp-core-dependencies-x86-centos-stream-9
151161
[core-deps-manylinux_2_28-x86_64]: https://github.com/y-scope/clp/pkgs/container/clp%2Fclp-core-dependencies-x86-manylinux_2_28
152162
[core-deps-musllinux_1_2-x86_64]: https://github.com/y-scope/clp/pkgs/container/clp%2Fclp-core-dependencies-x86-musllinux_1_2

docs/src/dev-docs/tooling-gh-workflows.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
The CLP repo includes several GitHub workflows for automating container image builds, artifact
44
builds, testing, and linting. We briefly describe each workflow below.
55

6-
## clp-core-build
6+
## clp-artifact-build
77

88
This workflow is responsible for:
99

10-
1. building (Linux) container images containing CLP-core's dependencies, and
11-
2. building CLP-core and running its unit tests.
10+
1. building (Linux) container images containing CLP-core's dependencies,
11+
2. building CLP-core and running its unit tests, and
12+
3. building a container image containing CLP's package components.
1213

1314
To minimize build times, the jobs in the workflow are organized in the directed acyclic graph (DAG)
1415
shown below.
@@ -40,6 +41,7 @@ flowchart LR
4041
manylinux_2_28-x86_64-deps-image --> manylinux_2_28-x86_64-binaries
4142
musllinux_1_2-x86_64-deps-image --> musllinux_1_2-x86_64-binaries
4243
ubuntu-jammy-deps-image --> ubuntu-jammy-binaries
44+
ubuntu-jammy-deps-image --> package-image
4345
ubuntu-jammy-binaries --> ubuntu-jammy-binaries-image
4446
:::
4547

@@ -61,6 +63,7 @@ Arrows between jobs indicate a dependency. The jobs are as follows:
6163
container and runs core's unit tests.
6264
* `musllinux_1_2-x86_64-binaries`: Builds the CLP-core binaries in the built musllinux_1_2 container
6365
and runs core's unit tests.
66+
* `package-image`: Builds a container image containing CLP's package components.
6467
* `ubuntu-jammy-binaries`: Builds the CLP-core binaries in the built Ubuntu Jammy container and runs
6568
core's unit tests.
6669
* `ubuntu-jammy-binaries-image`: Builds an Ubuntu Jammy container image containing CLP-core's

taskfile.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ shopt: ["globstar"]
55

66
includes:
77
deps: "taskfiles/deps/main.yaml"
8+
docker-images: "taskfiles/docker-images.yaml"
89
docs: "taskfiles/docs.yaml"
910
lint: "taskfiles/lint.yaml"
1011
utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
@@ -37,6 +38,7 @@ vars:
3738
{{default "" (env "CLP_CORE_MAX_PARALLELISM_PER_BUILD_TASK")}}
3839
3940
# Checksum files
41+
G_PACKAGE_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/package.md5"
4042
G_WEBUI_CLIENT_NODE_MODULES_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/webui-client-node-modules.md5"
4143
G_WEBUI_COMMON_NODE_MODULES_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/webui-common-node-modules.md5"
4244
G_WEBUI_LOG_VIEWER_NODE_MODULES_CHECKSUM_FILE:
@@ -94,7 +96,7 @@ tasks:
9496
env:
9597
NODE_ENV: "production"
9698
vars:
97-
CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK}}.md5"
99+
CHECKSUM_FILE: "{{.G_PACKAGE_CHECKSUM_FILE}}"
98100
OUTPUT_DIR: "{{.G_PACKAGE_BUILD_DIR}}"
99101
sources:
100102
- "{{.G_BUILD_DIR}}/package-venv.md5"

0 commit comments

Comments
 (0)