Skip to content

Commit

Permalink
Merge content bake definition into main bake definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpittwood committed Apr 10, 2024
1 parent cc14e96 commit e4468c0
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 228 deletions.
55 changes: 3 additions & 52 deletions .github/workflows/build-bake.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
on:
schedule:
- cron: '0 8 * * 1' # Every Monday at 8:00 UTC for automatic rebuilds (pull in OS updates, security patches, etc.)
push:
branches:
- main
Expand All @@ -9,7 +11,7 @@ name: Release - Build, Test, and Push
jobs:
build:
name: Build, Test, and Push images
runs-on: ubuntu-latest-4x
runs-on: ubuntu-latest-8x

concurrency:
group: bake-${{ github.ref }}
Expand Down Expand Up @@ -102,54 +104,3 @@ jobs:
*.cache-to=type=gha,compression=zstd
targets: "build"
push: true

build-content:
name: Build content images
runs-on: ubuntu-latest-4x

concurrency:
group: bake-content-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: ./share/buildkitd.toml

- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build
id: build
uses: docker/bake-action@v4
with:
set: |
*.cache-from=type=gha
*.cache-to=type=gha,compression=zstd
workdir: content/.
push: false

- name: Push
id: push
if: github.ref == 'refs/heads/main'
uses: docker/bake-action@v4
with:
set: |
*.cache-from=type=gha
*.cache-to=type=gha,compression=zstd
workdir: content/.
push: true
11 changes: 4 additions & 7 deletions content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,17 @@ DEBUG=1 ./scripts/build-image.sh \

## Build matrix

The json defined in `matrix.json` is loaded by the Github Action to
The `CONTENT_BUILD_MATRIX` variable defined in [the buildx bake definition](../docker-bake.hcl) is used to
determine which combinations of R and Python to use when building
our `content-base` and `content-pro` images. To add a new R and Python
version combination, simply update the matrix and the Github Action will publish
the new image combinations to our registries upon the next push to `main`
the new image combinations to our registries upon the next push to `main`.

**NOTE** This combination should be kept in sync with the `build-images.sh` script, as the
file `matrix.json` is used by Github Actions as described above, but the `build-images.sh` script
is used when the developer is validating the ability to build the new images locally.
To build content images locally, use `just bake content-images` from the repository root.

## Github Actions

Because of the dependency on the content-base images, the github actions that build the pro images
depend on completion of the base image builds in [build-content](../.github/workflows/build-content.yaml)
Content base and pro images are built in [build-bake](../.github/workflows/build-bake.yaml).

# Licensing

Expand Down
47 changes: 0 additions & 47 deletions content/base/Justfile

This file was deleted.

4 changes: 4 additions & 0 deletions content/base/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2024-04-10

- Change build orchestration to `buildx bake`

# 2023-04-26

- Use the Quarto release 1.3.340 in jammy images.
Expand Down
9 changes: 0 additions & 9 deletions content/base/README.md

This file was deleted.

48 changes: 0 additions & 48 deletions content/build-images.sh

This file was deleted.

48 changes: 0 additions & 48 deletions content/pro/Justfile

This file was deleted.

4 changes: 4 additions & 0 deletions content/pro/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2024-04-10

- Change build orchestration to `buildx bake`

# 2021-07-19

- Add NEWS.md
Expand Down
9 changes: 0 additions & 9 deletions content/pro/README.md

This file was deleted.

84 changes: 84 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,34 @@ variable CONNECT_CONTENT_INIT_BUILD_MATRIX {
}
}

variable CONTENT_BUILD_MATRIX {
default = {
builds = [
{os = "ubuntu1804", os_alt = "bionic", r = "3.1.3", py = "2.7.18", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.2.5", py = "2.7.18", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.3.3", py = "3.6.13", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.4.4", py = "3.6.13", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.4.4", py = "3.7.10", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.5.3", py = "2.7.18", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.5.3", py = "3.7.10", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.6.3", py = "2.7.18", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.6.3", py = "3.6.13", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "3.6.3", py = "3.8.8", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.0.5", py = "3.6.13", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.0.5", py = "3.7.10", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.0.5", py = "3.8.8", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.0.5", py = "3.9.2", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.1.0", py = "3.8.8", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.1.0", py = "3.9.2", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu1804", os_alt = "bionic", r = "4.1.3", py = "3.10.4", drivers = "2024.03.0", quarto = "1.0.37"},
{os = "ubuntu2204", os_alt = "jammy", r = "3.6.3", py = "3.8.16", drivers = "2024.03.0", quarto = "1.3.340"},
{os = "ubuntu2204", os_alt = "jammy", r = "4.0.5", py = "3.9.16", drivers = "2024.03.0", quarto = "1.3.340"},
{os = "ubuntu2204", os_alt = "jammy", r = "4.1.3", py = "3.10.11", drivers = "2024.03.0", quarto = "1.3.340"},
{os = "ubuntu2204", os_alt = "jammy", r = "4.2.2", py = "3.11.3", drivers = "2024.03.0", quarto = "1.3.340"},
]
}
}

variable R_SESSION_COMPLETE_BUILD_MATRIX {
default = {
builds = [
Expand Down Expand Up @@ -147,6 +175,8 @@ group "default" {
"product-base-pro",
"connect",
"connect-content-init",
"content-base",
"content-pro",
"package-manager",
"r-session-complete",
"workbench",
Expand All @@ -160,6 +190,13 @@ group "base-images" {
]
}

group "content-images" {
targets = [
"content-base",
"content-pro"
]
}

group "waml-images" {
targets = [
"build-workbench-for-microsoft-azure-ml",
Expand Down Expand Up @@ -293,6 +330,53 @@ target "connect-content-init" {
}
}

target "content-base" {
inherits = ["base"]
name = "content-base-r${replace(builds.r, ".", "-")}-py${replace(builds.py, ".", "-")}-${builds.os}"

tags = [
"ghcr.io/rstudio/content-base:r${builds.r}-py${builds.py}-${builds.os}",
"ghcr.io/rstudio/content-base:r${builds.r}-py${builds.py}-${builds.os_alt}",
"docker.io/rstudio/content-base:r${builds.r}-py${builds.py}-${builds.os}",
"docker.io.io/rstudio/content-base:r${builds.r}-py${builds.py}-${builds.os_alt}",
]

dockerfile = "Dockerfile.${builds.os}"
context = "content/base"

matrix = CONTENT_BUILD_MATRIX
args = {
R_VERSION = "${builds.r}"
PYTHON_VERSION = "${builds.py}"
QUARTO_VERSION = "${builds.quarto}"
}
}

target "content-pro" {
inherits = ["base"]
name = "content-pro-r${replace(builds.r, ".", "-")}-py${replace(builds.py, ".", "-")}-${builds.os}"

tags = [
"ghcr.io/rstudio/content-pro:r${builds.r}-py${builds.py}-${builds.os}",
"ghcr.io/rstudio/content-pro:r${builds.r}-py${builds.py}-${builds.os_alt}",
"docker.io/rstudio/content-pro:r${builds.r}-py${builds.py}-${builds.os}",
"docker.io.io/rstudio/content-pro:r${builds.r}-py${builds.py}-${builds.os_alt}",
]

contexts = {
content-base = "target:content-base-r${replace(builds.r, ".", "-")}-py${replace(builds.py, ".", "-")}-${builds.os}"
}

dockerfile = "Dockerfile.${builds.os}"
context = "content/pro"

matrix = CONTENT_BUILD_MATRIX
args = {
R_VERSION = "${builds.r}"
DRIVERS_VERSION = "${builds.drivers}"
}
}

### Workbench targets ###
target "r-session-complete" {
inherits = ["base"]
Expand Down
Loading

0 comments on commit e4468c0

Please sign in to comment.