Skip to content

Commit f30c01a

Browse files
authored
[DEVOPS-1591] Add CI configuration for building images (#11)
* Fix permissions on all files, add pre-commit configuration * Run pre-commit checks in github actions * Add docker bake file * Fix task configurations * Remove 3.11 for testing * Don't fail fast either * Quote versions * Replace hadolint * Add additional copies for R base image * Fix build targets for GPU * Remove GPU builds for now * Fix parsing of environment variable * Fix target processing * Use intermediate step to generate the target * Fix job name * Fix quoting * Prefix target with language * Fix rlang target * Set the appropriate targets for various builds * Remove 'main' target from rlang * Test pushing python kernels from pull request * Add labels * Add GPU builds * Fix variable usage * Syntax correction * Fix some more quoting * Fix if * Set base image * Fix bake contexts for GPU images * Also need to copy base files * Fix quoting * Copy GPU files all the time for testing * Use 8CPU runner group * Use public runner group * Rerun checks * Use github.ref_name for the tag * Fix quoting * Configure dynamic tags * Fix the tag variable syntax * Fix linting * Use script for setting TAG and TIMESTAMP * Add context to TODO comment * Fix typo * Use 1.5 Dockerfile syntax * Pin 3rd party workflows * Provide comments and links for description of bake configuration * Push images for another test * Add -base suffix to R base image * Disable PR builds again * Push some latest tags for testing * Revert builds to not use latest, or build on PRs
1 parent f50a760 commit f30c01a

File tree

20 files changed

+488
-86
lines changed

20 files changed

+488
-86
lines changed

.github/workflows/build.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,96 @@ jobs:
4949
5050
- name: Run pre-commit hooks ✅
5151
run: pre-commit run --all-files --hook-stage manual
52+
53+
build_python_kernels:
54+
runs-on:
55+
group: ubuntu-22.04-8cpu-public
56+
permissions:
57+
id-token: write
58+
packages: write
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
version: ["3.9", "3.10"] # TODO: Add 3.11 after fixing dependency conflicts
63+
identifier: [base, base-gpu]
64+
env:
65+
VERSION: ${{ matrix.version }}
66+
TARGET: python_${VERSION//./_}
67+
BUILD_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
68+
GITHUB_SHA: ${{ github.sha }}
69+
steps:
70+
- uses: actions/checkout@v3
71+
- name: Install Task
72+
uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1.0.3
73+
with:
74+
repo-token: ${{ github.token }}
75+
- run: |
76+
task python:base:copy-files IDENTIFIER="base" NBL_PYTHON_VERSION=${{ matrix.version }}
77+
if [[ "${{ matrix.identifier }}" == "base-gpu" ]];
78+
then
79+
task python:base:copy-files IDENTIFIER=${{ matrix.identifier }} NBL_PYTHON_VERSION=${{ matrix.version }}
80+
fi
81+
task python:noteable:copy-files IDENTIFIER=${{ matrix.identifier }} NBL_PYTHON_VERSION=${{ matrix.version }}
82+
- run: scripts/set-variables.sh ${{ github.ref_name }} ${{ github.event_name }} ${{ github.event.pull_request.number }}
83+
- uses: docker/login-action@v2
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.actor }}
87+
password: ${{ github.token }}
88+
- name: Set target
89+
id: target
90+
run: |
91+
if [[ "${{ matrix.identifier }}" == "base" ]]
92+
then
93+
target="python_${VERSION//./_}"
94+
else
95+
target="python_${VERSION//./_}_gpu"
96+
fi
97+
echo "TARGET=${target}" >> "$GITHUB_OUTPUT"
98+
99+
- uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.9.1
100+
101+
- name: Build python kernels
102+
env:
103+
uses: docker/bake-action@f32f8b8d70bc284af19f8148dd14ad1d2fbc6c28 # v3.1.0
104+
with:
105+
push: ${{ github.event_name != 'pull_request' }}
106+
targets: ${{ steps.target.outputs.TARGET }}
107+
108+
build_rlang_kernels:
109+
runs-on: ubuntu-22.04
110+
permissions:
111+
id-token: write
112+
packages: write
113+
strategy:
114+
matrix:
115+
version: [4.3.0]
116+
env:
117+
VERSION: ${{ matrix.version }}
118+
BUILD_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
119+
GITHUB_SHA: ${{ github.ref }}
120+
steps:
121+
- uses: actions/checkout@v3
122+
- name: Install Task
123+
uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1.0.3
124+
with:
125+
repo-token: ${{ github.token }}
126+
- run: |
127+
task r:base:copy-files NBL_LANGUAGE_VERSION=${{ matrix.version }}
128+
- run: scripts/set-variables.sh ${{ github.ref_name }} ${{ github.event_name }} ${{ github.event.pull_request.number }}
129+
- uses: docker/login-action@v2
130+
with:
131+
registry: ghcr.io
132+
username: ${{ github.actor }}
133+
password: ${{ github.token }}
134+
- name: Set target
135+
id: target
136+
run: echo "TARGET=rlang_${VERSION//./_}" >> "$GITHUB_OUTPUT"
137+
138+
- uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.9.1
139+
140+
- name: Build kernels
141+
uses: docker/bake-action@f32f8b8d70bc284af19f8148dd14ad1d2fbc6c28 # v3.1.0
142+
with:
143+
push: ${{ github.event_name != 'pull_request' }}
144+
targets: ${{ steps.target.outputs.TARGET }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Development files
2+
.idea
3+
14
# ignore these everywhere
25
.pythonrc
36
.Rprofile

R/base/4.3.0/Dockerfile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# syntax = docker/dockerfile:1.2.1
1+
# syntax = docker/dockerfile:1.5
22
# ---
33
# Bare minimum R 4.3.x image with IRkernel installed
44
# - no R packages aside from builtins and IRkernel
@@ -62,15 +62,3 @@ EXPOSE 50001-50005
6262

6363
ENTRYPOINT ["/tini", "-g", "--"]
6464
CMD ["run.sh"]
65-
66-
ARG NBL_ARG_BUILD_TIMESTAMP="undefined"
67-
ARG NBL_ARG_REVISION="undefined"
68-
ARG NBL_ARG_BUILD_URL="undefined"
69-
ARG NBL_ARG_VERSION="undefined"
70-
LABEL org.opencontainers.image.created="${NBL_ARG_BUILD_TIMESTAMP}" \
71-
org.opencontainers.image.revision="${NBL_ARG_REVISION}" \
72-
org.opencontainers.image.source="https://github.com/noteable-io/polymorph" \
73-
org.opencontainers.image.title="noteable-R-${NBL_R_VERSION}" \
74-
org.opencontainers.image.url="${NBL_ARG_BUILD_URL}" \
75-
org.opencontainers.image.vendor="Noteable" \
76-
org.opencontainers.image.version="${NBL_ARG_VERSION}"

R/noteable/4.3.0/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# syntax = docker/dockerfile:1.2.1
1+
# syntax = docker/dockerfile:1.5
22
# Noteable build: adds packages to enable Noteable-specific functionality:
33
# - DEX support (via .Rprofile)
4-
ARG BASE_IMAGE
54
# hadolint ignore=DL3006
6-
FROM ${BASE_IMAGE} as base
5+
FROM base
76

87
USER noteable
98

Taskfile.R.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ tasks:
2323
cmds:
2424
- task copy-root-files LANGUAGE=R IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_R_VERSION}}
2525
- task copy-language-files LANGUAGE=R IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_R_VERSION}}
26-
26+
- cp R/noteable/.Rprofile R/noteable/{{.NBL_R_VERSION}}/.Rprofile
27+
- cp R/noteable/requirements.R R/noteable/{{.NBL_R_VERSION}}/requirements.R
2728
base:build:
2829
desc: Build the R 4.x base image after copying required files
2930
cmds:

Taskfile.python.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ tasks:
2929
cmds:
3030
- task copy-root-files LANGUAGE=python IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}}
3131
- task copy-language-files LANGUAGE=python IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}}
32+
- cp python/base-gpu/environment.txt python/base-gpu/{{.NBL_PYTHON_VERSION}}/environment.txt
33+
- cp python/base-gpu/gpu.Aptfile python/base-gpu/{{.NBL_PYTHON_VERSION}}/gpu.Aptfile
34+
- cp python/base-gpu/run.sh python/base-gpu/{{.NBL_PYTHON_VERSION}}/run.sh
35+
- cp python/base-gpu/initial-condarc python/base-gpu/{{.NBL_PYTHON_VERSION}}/initial-condarc
3236

3337
base:pyenv:install:
3438
desc: Install the specified version of Python using pyenv

0 commit comments

Comments
 (0)