Skip to content

Commit a389070

Browse files
authored
Merge pull request #31 from posit-dev/workbench-session-images
Workbench session images
2 parents 6540e6f + 68ee00d commit a389070

17 files changed

+515
-1
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Product Images
22
on:
33
schedule:
44
# Weekly rebuild of all images, to pick up any upstream changes.
@@ -66,6 +66,7 @@ jobs:
6666
with:
6767
runs-on: ubuntu-latest-4x
6868
dev-versions: "exclude"
69+
matrix-versions: "exclude"
6970
# Push images only for merges into main and weekly schduled re-builds.
7071
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event.schedule == '15 3 * * 0' }}
7172

@@ -89,6 +90,7 @@ jobs:
8990
with:
9091
runs-on: ubuntu-latest-4x
9192
dev-versions: "only"
93+
matrix-versions: "exclude"
9294
aws-region: us-west-2
9395
# Push images only for merges into main and hourly schduled re-builds.
9496
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event.schedule == '45 4 * * *' }}

.github/workflows/session.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Session Images
2+
on:
3+
schedule:
4+
# Weekly rebuild of all images, to pick up any upstream changes.
5+
- cron: "15 4 * * 0" # At 04:15 on Sunday
6+
7+
pull_request:
8+
9+
push:
10+
branches:
11+
- main
12+
13+
concurrency:
14+
# Only cancel in-progress runs for pull_request events, this prevents cancelling workflows against main or tags
15+
# A pull_request will reuse the same group thus enabling cancelation, all others receive a unique run_id
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
21+
build:
22+
name: Build
23+
# Build all images, excluding dev versions.
24+
#
25+
# Builds all versions of each image in parallel.
26+
#
27+
# Run on merges to main, or on weekly scheduled re-builds.
28+
if: contains(fromJSON('["push", "pull_request"]'), github.event_name) || github.event.schedule == '15 3 * * 0'
29+
permissions:
30+
contents: read
31+
packages: write
32+
33+
uses: "posit-dev/images-shared/.github/workflows/bakery-build.yml@main"
34+
secrets:
35+
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
36+
with:
37+
runs-on: ubuntu-latest-4x
38+
matrix-versions: only
39+
# Push images only for merges into main and weekly schduled re-builds.
40+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event.schedule == '15 3 * * 0' }}
41+
42+
clean:
43+
name: Clean
44+
if: always() && github.ref == 'refs/heads/main'
45+
permissions:
46+
contents: read
47+
packages: write
48+
needs:
49+
- build
50+
51+
uses: "posit-dev/images-shared/.github/workflows/clean.yml@main"
52+
with:
53+
remove-dangling-caches: true
54+
remove-caches-older-than: 14
55+
# FIXME: re-enable temporary image cleanup after moving to native platform workflow
56+
# remove-dangling-temporary-images: false
57+
# remove-temporary-images-older-than: 3
58+
clean-temporary-images: false

bakery.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,22 @@ images:
154154
primary: true
155155
values:
156156
go_version: 1.22.2
157+
- name: workbench-session
158+
matrix:
159+
namePattern: "R{{ Dependencies.R }}-python{{ Dependencies.python }}"
160+
dependencyConstraints:
161+
- dependency: R
162+
constraint:
163+
min: "4.3"
164+
latest: true
165+
- dependency: python
166+
constraint:
167+
min: "3.11"
168+
latest: true
169+
- dependency: quarto
170+
constraint:
171+
latest: true
172+
os:
173+
- name: Ubuntu 24.04
174+
primary: true
175+
- name: Ubuntu 22.04
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Build Python using uv in a separate stage
2+
FROM ghcr.io/astral-sh/uv:bookworm-slim AS python-builder
3+
4+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
5+
ENV UV_PYTHON_INSTALL_DIR=/opt/python
6+
ENV UV_PYTHON_PREFERENCE=only-managed
7+
8+
ARG PYTHON_VERSION
9+
RUN uv python install $PYTHON_VERSION
10+
RUN mv /opt/python/cpython-$PYTHON_VERSION-linux-*/ /opt/python/$PYTHON_VERSION
11+
12+
13+
FROM docker.io/library/ubuntu:22.04
14+
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:22.04"
15+
16+
### ARG declarations ###
17+
ARG DEBIAN_FRONTEND=noninteractive
18+
ARG R_VERSION
19+
ARG PYTHON_VERSION
20+
ARG QUARTO_VERSION
21+
22+
### Install Apt Packages ###
23+
RUN apt-get update -yqq --fix-missing && \
24+
apt-get upgrade -yqq && \
25+
apt-get dist-upgrade -yqq && \
26+
apt-get autoremove -yqq --purge && \
27+
apt-get install -yqq --no-install-recommends \
28+
curl \
29+
ca-certificates \
30+
gnupg \
31+
tar && \
32+
bash -c "$(curl -1fsSL 'https://dl.posit.co/public/pro/setup.deb.sh')" && \
33+
apt-get clean -yqq && \
34+
rm -rf /var/lib/apt/lists/*
35+
36+
COPY workbench-session/matrix/deps/ubuntu-22.04_packages.txt /tmp/ubuntu-22.04_packages.txt
37+
RUN apt-get update -yqq && \
38+
xargs -a /tmp/ubuntu-22.04_packages.txt apt-get install -yqq --no-install-recommends && \
39+
apt-get clean -yqq && \
40+
rm -rf /var/lib/apt/lists/*
41+
42+
# Install Python from previous stage
43+
COPY --from=python-builder /opt/python /opt/python
44+
45+
### Install Jupyter ###
46+
RUN /opt/python/$PYTHON_VERSION/bin/python -m venv /opt/python/jupyter && \
47+
/opt/python/jupyter/bin/pip install --no-cache-dir --upgrade pip setuptools wheel && \
48+
/opt/python/jupyter/bin/pip install --no-cache-dir 'jupyterlab<5' notebook 'pwb_jupyterlab<2' && \
49+
ln -s /opt/python/jupyter/bin/jupyter /usr/local/bin/jupyter
50+
51+
### Install Jupyter kernel ###
52+
RUN /opt/python/$PYTHON_VERSION/bin/pip install --no-cache-dir --upgrade --break-system-packages \
53+
ipykernel && \
54+
/opt/python/$PYTHON_VERSION/bin/python -m ipykernel install --user --name python$PYTHON_VERSION --display-name "Python $PYTHON_VERSION"
55+
56+
# Install R
57+
RUN RUN_UNATTENDED=1 R_VERSION=$R_VERSION bash -c "$(curl -fsSL https://rstd.io/r-install)" && \
58+
find . -type f -name '[rR]-$R_VERSION.*\.(deb|rpm)' -delete
59+
60+
### Install Quarto and TinyTeX ###
61+
# Caches won't invalidate correctly on new releases for TinyTeX installs. This ADD instruction is a workaround to bust
62+
# the cache on new releases.
63+
ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json
64+
RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \
65+
curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \
66+
/opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet \
67+
&& rm -f /tmp/tinytex-release.json
68+
69+
### Install Quarto and TinyTeX ###
70+
ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json
71+
RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \
72+
curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \
73+
/opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet --update-path && \
74+
ln -s /opt/quarto/$QUARTO_VERSION/bin/quarto /usr/local/bin/quarto && \
75+
rm -f /tmp/tinytex-release.json
76+
77+
COPY workbench-session/matrix/conf/vscode.extensions.conf /etc/rstudio/vscode.extensions.conf
78+
COPY workbench-session/matrix/conf/positron.extensions.conf /etc/rstudio/positron.extensions.conf
79+
80+
EXPOSE 8788/tcp
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Build Python using uv in a separate stage
2+
FROM ghcr.io/astral-sh/uv:bookworm-slim AS python-builder
3+
4+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
5+
ENV UV_PYTHON_INSTALL_DIR=/opt/python
6+
ENV UV_PYTHON_PREFERENCE=only-managed
7+
8+
ARG PYTHON_VERSION
9+
RUN uv python install $PYTHON_VERSION
10+
RUN mv /opt/python/cpython-$PYTHON_VERSION-linux-*/ /opt/python/$PYTHON_VERSION
11+
12+
13+
FROM docker.io/library/ubuntu:24.04
14+
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:24.04"
15+
16+
### ARG declarations ###
17+
ARG DEBIAN_FRONTEND=noninteractive
18+
ARG R_VERSION
19+
ARG PYTHON_VERSION
20+
ARG QUARTO_VERSION
21+
22+
### Install Apt Packages ###
23+
RUN apt-get update -yqq --fix-missing && \
24+
apt-get upgrade -yqq && \
25+
apt-get dist-upgrade -yqq && \
26+
apt-get autoremove -yqq --purge && \
27+
apt-get install -yqq --no-install-recommends \
28+
curl \
29+
ca-certificates \
30+
gnupg \
31+
tar && \
32+
bash -c "$(curl -1fsSL 'https://dl.posit.co/public/pro/setup.deb.sh')" && \
33+
apt-get clean -yqq && \
34+
rm -rf /var/lib/apt/lists/*
35+
36+
COPY workbench-session/matrix/deps/ubuntu-24.04_packages.txt /tmp/ubuntu-24.04_packages.txt
37+
RUN apt-get update -yqq && \
38+
xargs -a /tmp/ubuntu-24.04_packages.txt apt-get install -yqq --no-install-recommends && \
39+
apt-get clean -yqq && \
40+
rm -rf /var/lib/apt/lists/*
41+
42+
# Install Python from previous stage
43+
COPY --from=python-builder /opt/python /opt/python
44+
45+
### Install Jupyter ###
46+
RUN /opt/python/$PYTHON_VERSION/bin/python -m venv /opt/python/jupyter && \
47+
/opt/python/jupyter/bin/pip install --no-cache-dir --upgrade pip setuptools wheel && \
48+
/opt/python/jupyter/bin/pip install --no-cache-dir 'jupyterlab<5' notebook 'pwb_jupyterlab<2' && \
49+
ln -s /opt/python/jupyter/bin/jupyter /usr/local/bin/jupyter
50+
51+
### Install Jupyter kernel ###
52+
RUN /opt/python/$PYTHON_VERSION/bin/pip install --no-cache-dir --upgrade --break-system-packages \
53+
ipykernel && \
54+
/opt/python/$PYTHON_VERSION/bin/python -m ipykernel install --user --name python$PYTHON_VERSION --display-name "Python $PYTHON_VERSION"
55+
56+
# Install R
57+
RUN RUN_UNATTENDED=1 R_VERSION=$R_VERSION bash -c "$(curl -fsSL https://rstd.io/r-install)" && \
58+
find . -type f -name '[rR]-$R_VERSION.*\.(deb|rpm)' -delete
59+
60+
### Install Quarto and TinyTeX ###
61+
# Caches won't invalidate correctly on new releases for TinyTeX installs. This ADD instruction is a workaround to bust
62+
# the cache on new releases.
63+
ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json
64+
RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \
65+
curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \
66+
/opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet \
67+
&& rm -f /tmp/tinytex-release.json
68+
69+
### Install Quarto and TinyTeX ###
70+
ADD https://api.github.com/repos/rstudio/tinytex-releases/releases/latest /tmp/tinytex-release.json
71+
RUN mkdir -p /opt/quarto/$QUARTO_VERSION && \
72+
curl -fsSL "https://github.com/quarto-dev/quarto-cli/releases/download/v$QUARTO_VERSION/quarto-$QUARTO_VERSION-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/$QUARTO_VERSION" --strip-components=1 && \
73+
/opt/quarto/$QUARTO_VERSION/bin/quarto install tinytex --no-prompt --quiet --update-path && \
74+
ln -s /opt/quarto/$QUARTO_VERSION/bin/quarto /usr/local/bin/quarto && \
75+
rm -f /tmp/tinytex-release.json
76+
77+
COPY workbench-session/matrix/conf/vscode.extensions.conf /etc/rstudio/vscode.extensions.conf
78+
COPY workbench-session/matrix/conf/positron.extensions.conf /etc/rstudio/positron.extensions.conf
79+
80+
EXPOSE 8788/tcp
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
posit.shiny
2+
posit.publisher
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
quarto.quarto
2+
REditorSupport.r@2.8.2
3+
ms-python.python
4+
posit.shiny
5+
ms-toolsai.jupyter
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ca-certificates
2+
curl
3+
git
4+
krb5-user
5+
libpq-dev
6+
libuser
7+
libuser1-dev
8+
rrdtool
9+
rstudio-drivers
10+
subversion
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ca-certificates
2+
curl
3+
git
4+
krb5-user
5+
libpq-dev
6+
libuser
7+
libuser1-dev
8+
rrdtool
9+
rstudio-drivers
10+
subversion
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package:
2+
{{ $apt_package_list_path := printf "/tmp/version/deps/%s-%s_packages.txt" .Env.IMAGE_OS_NAME .Env.IMAGE_OS_VERSION }}
3+
{{ $apt_package_list := readFile $apt_package_list_path | splitList "\n" }}
4+
{{- range $apt_package_list }}
5+
{{.}}:
6+
installed: true
7+
{{end}}
8+
9+
file:
10+
python-{{ .Env.BUILD_ARG_PYTHON_VERSION }}:
11+
exists: true
12+
path: /opt/python/{{ .Env.BUILD_ARG_PYTHON_VERSION }}
13+
r-{{ .Env.BUILD_ARG_R_VERSION }}:
14+
exists: true
15+
path: /opt/R/{{ .Env.BUILD_ARG_R_VERSION }}
16+
quarto-{{ .Env.BUILD_ARG_QUARTO_VERSION }}:
17+
exists: true
18+
path: /opt/quarto/{{ .Env.BUILD_ARG_QUARTO_VERSION }}
19+
20+
command:
21+
"Verify Jupyter Notebook works":
22+
exec: "echo '{ \"cells\": [], \"metadata\": {}, \"nbformat\": 4, \"nbformat_minor\": 2}' | /opt/python/jupyter/bin/jupyter nbconvert --to notebook --stdin --stdout"
23+
timeout: 60000
24+
exit-status: 0
25+
"Verify R installation is version {{ .Env.BUILD_ARG_R_VERSION }}":
26+
exec: /opt/R/{{ .Env.BUILD_ARG_R_VERSION }}/bin/R --version
27+
exit-status: 0
28+
stdout:
29+
- "R version {{ .Env.BUILD_ARG_R_VERSION }}"
30+
"Verify Python installation is version {{ .Env.BUILD_ARG_PYTHON_VERSION }}":
31+
exec: /opt/python/{{ .Env.BUILD_ARG_PYTHON_VERSION }}/bin/python --version
32+
exit-status: 0
33+
stdout:
34+
- "{{ .Env.BUILD_ARG_PYTHON_VERSION }}"
35+
"Verify Jupyter installation Python version":
36+
exec: /opt/python/jupyter/bin/python --version
37+
exit-status: 0
38+
stdout:
39+
- "{{ .Env.BUILD_ARG_PYTHON_VERSION }}"
40+
"Verify Quarto":
41+
exec: /usr/local/bin/quarto check --quiet
42+
exit-status: 0
43+
"Verify Quarto has TinyTeX installed":
44+
exec: quarto list tools
45+
exit-status: 0
46+
stderr:
47+
- "/tinytex\\s+Up to date/"

0 commit comments

Comments
 (0)