Skip to content

Commit

Permalink
Update README.md for bake changes
Browse files Browse the repository at this point in the history
Change `build` targets to aliases

Add a `run` target that leverages docker compose

Remove duplicated targets from bake definitions
  • Loading branch information
ianpittwood committed Apr 10, 2024
1 parent 2d00ee8 commit cc14e96
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 133 deletions.
41 changes: 28 additions & 13 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ PYTHON_VERSION_ALT_RHEL := "3.8.15"

QUARTO_VERSION := "1.3.450"

export RSC_LICENSE := ""
export RSPM_LICENSE := ""
export RSW_LICENSE := ""

# Targets for managing the buildx builder for Posit images

# just create-builder
Expand All @@ -40,11 +44,15 @@ delete-builder:
# Build and bake

# just bake workbench-images
build:
just bake "default"
bake target:
just -f {{justfile()}} create-builder || true
docker buildx bake --builder=posit-builder -f docker-bake.hcl {{target}}

# just preview-bake workbench-images dev
preview-build:
just preview-bake "default"
preview-bake target branch="$(git branch --show-current)":
just -f {{justfile()}} create-builder || true
WORKBENCH_DAILY_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local) \
Expand Down Expand Up @@ -72,19 +80,6 @@ preview-plan branch="$(git branch --show-current)":
BRANCH="{{branch}}" \
docker buildx bake -f docker-bake.preview.hcl --print

# just build
build:
just -f {{justfile()}} bake build

# just preview-build dev
preview-build branch="$(git branch --show-current)":
WORKBENCH_DAILY_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local) \
WORKBENCH_PREVIEW_VERSION=$(just -f ci.Justfile get-version workbench --type=preview --local) \
PACKAGE_MANAGER_DAILY_VERSION=$(just -f ci.Justfile get-version package-manager --type=daily --local) \
CONNECT_DAILY_VERSION=$(just -f ci.Justfile get-version connect --type=daily --local) \
BRANCH="{{branch}}" \
just -f {{justfile()}} preview-bake build

# Run tests

# just test
Expand Down Expand Up @@ -121,6 +116,26 @@ lint $PRODUCT $OS:
#!/usr/bin/env bash
docker run --rm -i -v $PWD/hadolint.yaml:/.config/hadolint.yaml ghcr.io/hadolint/hadolint < $PRODUCT/Dockerfile.$(just _parse-os {{OS}})
# Run targets

run product tag="":
#!/bin/bash
RSC_VERSION="ubuntu2204"
RSW_VERSION="ubuntu2204"
RSPM_VERSION="ubuntu2204"
if [ "{{product}}" = "workbench" ] && [ -z "{{tag}}" ]; then
RSW_VERSION="{{tag}}"
elif [ "{{product}}" = "connect" ] && [ -z "{{tag}}" ]; then
RSC_VERSION="{{tag}}"
elif [ "{{product}}" = "package-manager" ] && [ -z "{{tag}}" ]; then
RSPM_VERSION="{{tag}}"
fi
docker compose run \
-e RSW_VERSION="${RSW_VERSION}" \
-e RSC_VERSION="${RSC_VERSION}" \
-e RSPM_VERSION="${RSPM_VERSION}" \
{{product}}

# Helper targets

# just _get-tag-safe-version 2022.07.2+576.pro12
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,41 +122,41 @@ own containers fairly simply with the provided Justfiles. If you're unfamiliar w
most targets in each Justfile can be copy/pasted into your shell and ran there with variables replaced where
appropriate.

We now orchestrate all our builds using `docker buildx bake`. You can learn more about the tool on
[Docker's buildx bake page](https://docs.docker.com/build/bake/), however no additional background knowledge is needed
on the tool in order to use it.
We orchestrate all our builds using `docker buildx bake`. You can learn more about the tool on
[Docker's buildx bake page](https://docs.docker.com/build/bake/), however no additional background knowledge is needed on the tool in order
to use it.

To build all images:
```bash
just build
```
Individual images or groups of images can also be built:
Individual images or groups of images can also be built. For example, you can build `connect` by running:
```bash
just bake connect-images
just bake connect
```

Here are the available targets and groups in bake. To build one, use `just bake <target>`:
- `build` - Builds all images
- `base-images` - Builds `product/base` and `product/pro`
- `package-manager-images` - Builds `package-manager`
- `connect-images` - Builds `connect`
- `workbench-images` - Builds `workbench`
- `connect-content-images` - Builds `connect-content-init`
- `r-session-complete-images` - Builds `r-session-complete`
- `wgcw-images` - Builds `workbench-for-google-cloud-workstations`
- `waml-images` - Builds `workbench-for-microsoft-azure-ml`
- `package-manager` - Builds `package-manager`
- `connect` - Builds `connect`
- `workbench` - Builds `workbench`
- `connect-content-init` - Builds `connect-content-init`
- `r-session-complete` - Builds `r-session-complete`
- `workbench-for-google-cloud-workstations` - Builds `workbench-for-google-cloud-workstations`
- `waml-images` - Builds `workbench-for-microsoft-azure-ml` stack (build, scan, and final)

Preview images and content images are also available to build through the `docker-bake.preview.hcl` and
`content/docker-bake.hcl` files respectively or use `just preview-bake` and `just content-bake`.

You can alter what exactly is built by changing `workbench/Dockerfile.$OS`, `connect/Dockerfile.$OS`,
and `package-manager/Dockerfile.$OS`. Keep in mind that `product/base` or `product/pro` also impact what our default
images contain.
image builds contain.

You can then run what you've built to test out with the `run` commands. For instance, to run the workbench container
You can then run what you've built to test out with the `run` target. For instance, to run the workbench container
you have built:
```
just workbench/run
just RSW_LICENSE="<license key>" run workbench
```

Note you must have a license in place, and all other instructions in separate sections are still relevant.
Expand Down
48 changes: 0 additions & 48 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -153,61 +153,13 @@ group "default" {
]
}

group "build" {
targets = [
"product-base",
"product-base-pro",
"connect",
"connect-content-init",
"package-manager",
"r-session-complete",
"workbench",
]
}

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

group "package-manager-images" {
targets = [
"package-manager",
]
}

group "connect-images" {
targets = [
"connect",
]
}

group "connect-content-init-images" {
targets = [
"connect-content-init",
]
}

group "r-session-complete-images" {
targets = [
"r-session-complete",
]
}

group "workbench-images" {
targets = [
"workbench",
]
}

group "wgcw-images" {
targets = [
"workbench-for-google-cloud-workstations",
]
}

group "waml-images" {
targets = [
"build-workbench-for-microsoft-azure-ml",
Expand Down
32 changes: 0 additions & 32 deletions docker-bake.preview.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -167,45 +167,13 @@ group "default" {
]
}

group "build" {
targets = [
"product-base-dev",
"product-base-pro-dev",
"connect-daily",
"connect-content-init-daily",
"package-manager-daily",
"r-session-complete-preview",
"r-session-complete-daily",
"workbench-preview",
"workbench-daily",
]
}

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

group "package-manager-daily-images" {
targets = [
"package-manager-daily",
]
}

group "connect-daily-images" {
targets = [
"connect-daily",
]
}

group "connect-content-init-daily-images" {
targets = [
"connect-content-init-daily",
]
}

group "r-session-complete-images" {
targets = [
"r-session-complete-daily",
Expand Down
35 changes: 10 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
version: "3.5"

services:
rstudio-workbench:
workbench:
container_name: rstudio-workbench
build:
context: ./workbench
dockerfile: "Dockerfile.${IMAGE_OS:-ubuntu2204}"
args:
RSW_VERSION: 2023.12.1+402.pro1
image: rstudio/rstudio-workbench:2023.12.1
image: rstudio/rstudio-workbench:${RSW_VERSION:-ubuntu2204}
environment:
RSW_LICENSE: ${RSW_LICENSE}
LICENSE_SERVER: ${RSW_LICENSE_SERVER}
ports:
- 8787:8787
- 5559:5559
- "8787:8787"
- "5559:5559"
volumes:
- ./workbench/conf/:/etc/rstudio
- ./data/rsw:/home

rstudio-connect:
connect:
container_name: rstudio-connect
build:
context: ./connect
dockerfile: "Dockerfile.${IMAGE_OS:-ubuntu1804}"
args:
RSC_VERSION: 2024.02.0
image: rstudio/rstudio-connect:2024.02.0
image: rstudio/rstudio-connect:${RSC_VERSION:-ubuntu2204}
privileged: true
environment:
RSC_LICENSE: ${RSC_LICENSE}
LICENSE_SERVER: ${RSC_LICENSE_SERVER}
ports:
- 3939:3939
- "3939:3939"
volumes:
- ./connect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg
- ./data/rsc:/data

rstudio-package-manager:
package-manager:
container_name: rstudio-package-manager
build:
context: ./package-manager
dockerfile: "Dockerfile.${IMAGE_OS:-ubuntu2204}"
args:
RSPM_VERSION: 2023.12.0-13
image: rstudio/rstudio-package-manager:2023.12.0
image: rstudio/rstudio-package-manager:${RSPM_VERSION:-ubuntu2204}
environment:
RSPM_LICENSE: ${RSPM_LICENSE}
LICENSE_SERVER: ${RSPM_LICENSE_SERVER}
ports:
- 4242:4242
- "4242:4242"
volumes:
- ./package-manager/rstudio-pm.gcfg:/etc/rstudio-pm/rstudio-pm.gcfg
- ./data/rspm:/data

0 comments on commit cc14e96

Please sign in to comment.