Skip to content

Commit 94d4b6b

Browse files
authored
Merge pull request #876 from rstudio/dev
Workbench session image promotion
2 parents 34acb6c + 1d62002 commit 94d4b6b

21 files changed

+781
-31
lines changed

.github/workflows/build-bake.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,112 @@ jobs:
290290
snyk-org: ${{ secrets.SNYK_ORG }}
291291
snyk-token: '${{ secrets.SNYK_TOKEN }}'
292292

293+
workbench-session:
294+
needs: [setup]
295+
name: Workbench Session
296+
runs-on: ubuntu-latest-8x
297+
298+
concurrency:
299+
group: bake-workbench-session-${{ github.ref }}
300+
cancel-in-progress: true
301+
302+
env:
303+
target: workbench-session
304+
GIT_SHA: ${{ needs.setup.outputs.GIT_SHA }}
305+
306+
steps:
307+
- name: Checkout
308+
if: github.event_name == 'schedule'
309+
uses: actions/checkout@v4
310+
with:
311+
ref: 'main'
312+
313+
- name: Checkout
314+
if: github.event_name != 'schedule'
315+
uses: actions/checkout@v4
316+
317+
- name: Set up Docker Buildx
318+
uses: docker/setup-buildx-action@v3
319+
id: setup-buildx
320+
with:
321+
buildkitd-config: ./share/buildkitd.toml
322+
323+
- name: Build, Test, and Push
324+
uses: ./.github/actions/bake-test-push
325+
with:
326+
target: ${{ env.target }}
327+
push-image: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }}
328+
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
329+
dockerhub-username: ${{ secrets.DOCKER_HUB_USERNAME }}
330+
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
331+
gcp-json: '${{ secrets.GCP_ARTIFACT_REGISTRY_JSON }}'
332+
snyk-org: ${{ secrets.SNYK_ORG }}
333+
snyk-token: '${{ secrets.SNYK_TOKEN }}'
334+
335+
workbench-session-init:
336+
if: false # TODO: Re-enable this job after next release
337+
needs: [setup]
338+
name: Workbench Session Init
339+
runs-on: ubuntu-latest-8x
340+
341+
concurrency:
342+
group: bake-workbench-session-init-${{ github.ref }}
343+
cancel-in-progress: true
344+
345+
env:
346+
target: workbench-session-init
347+
GIT_SHA: ${{ needs.setup.outputs.GIT_SHA }}
348+
349+
steps:
350+
- name: Checkout
351+
if: github.event_name == 'schedule'
352+
uses: actions/checkout@v4
353+
with:
354+
ref: 'main'
355+
356+
- name: Checkout
357+
if: github.event_name != 'schedule'
358+
uses: actions/checkout@v4
359+
360+
- name: Set up Docker Buildx
361+
uses: docker/setup-buildx-action@v3
362+
id: setup-buildx
363+
with:
364+
buildkitd-config: ./share/buildkitd.toml
365+
366+
- name: Set up Just
367+
uses: extractions/setup-just@v2
368+
env:
369+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
370+
371+
- uses: actions/setup-python@v5
372+
with:
373+
python-version: '3.12'
374+
375+
- name: Install Python dependencies
376+
run: |
377+
pip install requests
378+
379+
- name: Get Version
380+
id: get-version
381+
run: |
382+
WORKBENCH_SESSION_INIT_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local)
383+
echo "WORKBENCH_SESSION_INIT_VERSION=$WORKBENCH_SESSION_INIT_VERSION" >> $GITHUB_OUTPUT
384+
385+
- name: Build, Test, and Push
386+
env:
387+
WORKBENCH_SESSION_INIT_VERSION: ${{ steps.get-version.outputs.WORKBENCH_SESSION_INIT_VERSION }}
388+
uses: ./.github/actions/bake-test-push
389+
with:
390+
target: ${{ env.target }}
391+
push-image: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }}
392+
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
393+
dockerhub-username: ${{ secrets.DOCKER_HUB_USERNAME }}
394+
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
395+
gcp-json: '${{ secrets.GCP_ARTIFACT_REGISTRY_JSON }}'
396+
snyk-org: ${{ secrets.SNYK_ORG }}
397+
snyk-token: '${{ secrets.SNYK_TOKEN }}'
398+
293399
workbench:
294400
needs: [setup]
295401
name: Workbench

.github/workflows/build-manual.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ jobs:
141141
product="CONNECT"
142142
elif [[ "$product" == "package-manager" ]]; then
143143
product="PACKAGE_MANAGER"
144+
elif [[ "$product" == "workbench-session-init" ]]; then
145+
product="WORKBENCH_SESSION_INIT"
144146
else
145147
product="WORKBENCH"
146148
fi

Justfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ delete-builder:
4949
alias build := bake
5050
# just bake workbench-images
5151
bake target="default":
52+
#!/bin/bash
5253
just -f {{justfile()}} create-builder || true
54+
if [ -z "$WORKBENCH_SESSION_INIT_VERSION" ]; then
55+
WORKBENCH_SESSION_INIT_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local)
56+
fi
5357
GIT_SHA=$(git rev-parse --short HEAD) \
58+
WORKBENCH_SESSION_INIT_VERSION=${WORKBENCH_SESSION_INIT_VERSION} \
5459
docker buildx bake --builder=posit-builder -f docker-bake.hcl {{target}}
5560

5661
# just preview-bake workbench-images dev
57-
preview-build:
58-
just preview-bake "default"
62+
alias preview-build := preview-bake
5963
preview-bake target branch="$(git branch --show-current)":
6064
just -f {{justfile()}} create-builder || true
6165
WORKBENCH_DAILY_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local) \
@@ -89,7 +93,12 @@ preview-plan branch="$(git branch --show-current)":
8993

9094
# just test workbench
9195
test target="default" file="docker-bake.hcl":
96+
#!/bin/bash
97+
if [ -z "$WORKBENCH_SESSION_INIT_VERSION" ]; then
98+
WORKBENCH_SESSION_INIT_VERSION=$(just -f ci.Justfile get-version workbench --type=daily --local)
99+
fi
92100
GIT_SHA=$(git rev-parse --short HEAD) \
101+
WORKBENCH_SESSION_INIT_VERSION=${WORKBENCH_SESSION_INIT_VERSION} \
93102
python3 {{justfile_directory()}}/tools/test_bake_artifacts.py --target "{{target}}" --file "{{file}}"
94103

95104
# just preview-test connect dev

docker-bake.hcl

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ variable WORKBENCH_VERSION {
1111
default = "2024.09.1+394.pro7"
1212
}
1313

14+
variable WORKBENCH_SESSION_INIT_VERSION {
15+
default = ""
16+
}
17+
1418
variable DRIVERS_VERSION {
1519
default = "2024.03.0"
1620
}
@@ -181,6 +185,18 @@ variable WORKBENCH_BUILD_MATRIX {
181185
}
182186
}
183187

188+
variable WORKBENCH_SESSION_MATRIX {
189+
default = PRO_BUILD_MATRIX
190+
}
191+
192+
variable WORKBENCH_SESSION_INIT_BUILD_MATRIX {
193+
default = {
194+
builds = [
195+
{os = "ubuntu2204"},
196+
]
197+
}
198+
}
199+
184200
variable WORKBENCH_GOOGLE_CLOUD_WORKSTATION_BUILD_MATRIX {
185201
default = {
186202
builds = [
@@ -209,6 +225,8 @@ group "default" {
209225
"package-manager",
210226
"r-session-complete",
211227
"workbench",
228+
"workbench-session",
229+
"workbench-session-init",
212230
]
213231
}
214232

@@ -428,6 +446,31 @@ target "r-session-complete" {
428446
}
429447
}
430448

449+
target "workbench-session" {
450+
inherits = ["base"]
451+
name = "workbench-session-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"
452+
453+
tags = [
454+
"ghcr.io/rstudio/workbench-session:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}",
455+
"docker.io/rstudio/workbench-session:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}",
456+
]
457+
458+
dockerfile = "Dockerfile.${builds.os}"
459+
context = "workbench-session"
460+
contexts = {
461+
product-base-pro = "target:product-base-pro-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"
462+
}
463+
464+
matrix = WORKBENCH_SESSION_MATRIX
465+
args = {
466+
R_VERSION = builds.r_primary
467+
R_VERSION_ALT = builds.r_alternate
468+
PYTHON_VERSION = builds.py_primary
469+
PYTHON_VERSION_ALT = builds.py_alternate
470+
JUPYTERLAB_VERSION = DEFAULT_JUPYTERLAB_VERSION
471+
}
472+
}
473+
431474
target "workbench" {
432475
inherits = ["base"]
433476

@@ -453,6 +496,23 @@ target "workbench" {
453496
}
454497
}
455498

499+
target "workbench-session-init" {
500+
inherits = ["base"]
501+
target = "build"
502+
503+
name = "workbench-session-init-${builds.os}-${replace(tag_safe_version(WORKBENCH_SESSION_INIT_VERSION), ".", "-")}"
504+
tags = get_tags(builds.os, "workbench-session-init", WORKBENCH_SESSION_INIT_VERSION)
505+
506+
dockerfile = "Dockerfile.${builds.os}"
507+
context = "workbench-session-init"
508+
509+
matrix = WORKBENCH_SESSION_INIT_BUILD_MATRIX
510+
511+
args = {
512+
RSW_VERSION = WORKBENCH_SESSION_INIT_VERSION
513+
}
514+
}
515+
456516
### Workbench for Google Cloud Workstations targets ###
457517
target "workbench-for-google-cloud-workstations" {
458518
inherits = ["base"]
Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04 AS build
1+
FROM ubuntu:22.04 AS builder
22

33
# Install required tools:
44
# - ca-certificates installs necessary certificates to use cURL with HTTPS websites
@@ -9,17 +9,44 @@ RUN apt-get update && \
99
rm -rf /var/lib/apt/lists/*
1010

1111
ARG RSW_VERSION=2024.09.1+394.pro7
12+
ARG GO_VERSION=1.22.2
1213

14+
# Download the RStudio Workbench session components and install Go
1315
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1416
RUN mkdir -p /pwb-staging && \
1517
RSW_VERSION_URL=$(echo -n "${RSW_VERSION}" | sed 's/+/-/g') && \
16-
echo "Downloading https://s3.amazonaws.com/rstudio-ide-build/session/multi/x86_64/rsp-session-multi-linux-${RSW_VERSION_URL}-x86_64.tar.gz" && \
1718
curl -fsSL -o /pwb-staging/rsp-session-multi-linux.tar.gz "https://s3.amazonaws.com/rstudio-ide-build/session/multi/x86_64/rsp-session-multi-linux-${RSW_VERSION_URL}-x86_64.tar.gz" && \
1819
mkdir -p /opt/session-components && \
19-
tar -C /opt/session-components -xf /pwb-staging/rsp-session-multi-linux.tar.gz && \
20-
chmod -R 755 /opt/session-components && \
20+
tar -C /opt/session-components -xpf /pwb-staging/rsp-session-multi-linux.tar.gz && \
21+
chmod 755 /opt/session-components && \
22+
curl -fsSL -o /pwb-staging/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \
23+
tar -C /usr/local -xf /pwb-staging/go.tar.gz && \
2124
rm -rf /pwb-staging
2225

23-
COPY --chmod=755 run.sh /usr/local/bin/run.sh
26+
# Add Go binary to PATH
27+
ENV PATH="/usr/local/go/bin:$PATH"
28+
29+
# Set the Go workspace
30+
WORKDIR /workspace
31+
32+
# Copy the Go source code and download dependencies
33+
COPY entrypoint/go.mod entrypoint/go.sum ./
34+
RUN go mod download
35+
36+
# Copy the Go source code and build the binary
37+
COPY entrypoint/main.go .
38+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-s -w' -o entrypoint main.go
39+
40+
# Create the final image
41+
FROM ubuntu:22.04 AS build
42+
43+
ARG DEBIAN_FRONTEND=noninteractive
44+
RUN apt-get update && \
45+
apt-get install -y --no-install-recommends ca-certificates curl && \
46+
rm -rf /var/lib/apt/lists/*
47+
48+
# Copy the compiled Go binary and session components from the builder stage
49+
COPY --from=builder --chmod=755 /workspace/entrypoint /usr/local/bin/entrypoint
50+
COPY --from=builder --chmod=755 /opt/session-components /opt/session-components
2451

25-
ENTRYPOINT ["/usr/local/bin/run.sh"]
52+
ENTRYPOINT ["/usr/local/bin/entrypoint"]

workbench-session-init/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ This directory contains a Dockerfile and script that will create an init contain
77
* Maintained by: [the Posit Docker team](https://github.com/rstudio/rstudio-docker-products)
88
* Where to get help: [our Github Issues page](https://github.com/rstudio/rstudio-docker-products/issues)
99
* Posit Workbench image: [Docker Hub](https://hub.docker.com/r/rstudio/rstudio-workbench)
10-
* RStudio r-session-complete image: [Docker Hub](https://hub.docker.com/r/rstudio/r-session-complete)
11-
* Workbench Session Init image (Daily/Preview): [Docker Hub](https://hub.docker.com/r/rstudio/rstudio-workbench-session-init-preview)
10+
* Posit Workbench session image: [Docker Hub](https://hub.docker.com/r/rstudio/workbench-session)
11+
* Posit Workbench session init image: [Docker Hub](https://hub.docker.com/r/rstudio/workbench-session-init)
1212

1313
## Supported tags and respective Dockerfile links
1414

1515
* [`jammy-daily`, `ubuntu2204-daily`, `jammy-2024.11.0`, `ubuntu2204-2024.11.0`](https://github.com/rstudio/rstudio-docker-products/blob/main/workbench-session-init/Dockerfile.2204)
1616

1717
## Building
1818

19-
Currently daily builds are supported. To build the image, run:
19+
Just will build an image using a default Connect distribution.
20+
21+
```console
22+
just build
23+
```
24+
25+
Daily builds are also supported. To build the daily image, run:
2026

2127
```console
2228
just preview-bake workbench-session-init-daily
@@ -28,14 +34,14 @@ You can observe what gets copied by the container:
2834

2935
```console
3036
mkdir init
31-
docker run --rm -v $(pwd)/init:/mnt/init rstudio/workbench-session-init-preview:workbench-session-init-jammy-2024.11.0-daily-328.pro3
37+
docker run --rm -v $(pwd)/init:/mnt/init rstudio/workbench-session-init:jammy-2024.11.0
3238
# The init directory has been populated with the Workbench session runtime components.
3339
```
3440

3541
You can also test using GOSS:
3642

3743
```console
38-
just preview-test workbench-session-init-daily
44+
just test workbench-session-init
3945
```
4046

4147
## Licensing
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module entrypoint
2+
3+
go 1.22.2
4+
5+
require (
6+
github.com/otiai10/copy v1.14.0 // indirect
7+
golang.org/x/sync v0.3.0 // indirect
8+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
9+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
2+
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
3+
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
4+
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
5+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
6+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)