From cc14e96e8722d5ec1e1efd28c70528125330a540 Mon Sep 17 00:00:00 2001 From: Ian Pittwood Date: Wed, 10 Apr 2024 13:03:29 -0700 Subject: [PATCH] Update README.md for bake changes Change `build` targets to aliases Add a `run` target that leverages docker compose Remove duplicated targets from bake definitions --- Justfile | 41 ++++++++++++++++++++++++----------- README.md | 30 +++++++++++++------------- docker-bake.hcl | 48 ----------------------------------------- docker-bake.preview.hcl | 32 --------------------------- docker-compose.yml | 35 +++++++++--------------------- 5 files changed, 53 insertions(+), 133 deletions(-) diff --git a/Justfile b/Justfile index c2b56aa47..643abcac6 100644 --- a/Justfile +++ b/Justfile @@ -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 @@ -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) \ @@ -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 @@ -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 diff --git a/README.md b/README.md index f4c134016..5e813e395 100644 --- a/README.md +++ b/README.md @@ -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 `: - `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="" run workbench ``` Note you must have a license in place, and all other instructions in separate sections are still relevant. diff --git a/docker-bake.hcl b/docker-bake.hcl index 77fd42633..65287d29d 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -153,18 +153,6 @@ 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", @@ -172,42 +160,6 @@ group "base-images" { ] } -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", diff --git a/docker-bake.preview.hcl b/docker-bake.preview.hcl index 3f143abd6..d7754bbec 100644 --- a/docker-bake.preview.hcl +++ b/docker-bake.preview.hcl @@ -167,20 +167,6 @@ 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", @@ -188,24 +174,6 @@ group "base-dev-images" { ] } -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", diff --git a/docker-compose.yml b/docker-compose.yml index 88ef5b309..35c22da8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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