Skip to content

Commit a7ff244

Browse files
authored
Merge pull request #5 from posit-dev/update-workbench-setup
Update Workbench image setup for newest `bakery` and `pti`
2 parents 037bf07 + ace0fa9 commit a7ff244

File tree

66 files changed

+517
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+517
-428
lines changed

.github/workflows/build-test-push.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,52 @@ jobs:
99
ubuntu:
1010
env:
1111
image-name: 'ubuntu'
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-latest-4x
1313
steps:
14+
15+
- name: GitHub App Token
16+
uses: actions/create-github-app-token@v1
17+
id: app-token
18+
with:
19+
app-id: ${{ secrets.APP_ID }}
20+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
21+
owner: posit-dev
22+
repositories: |
23+
images-workbench
24+
images-shared
25+
pti
26+
1427
- name: Checkout
1528
uses: actions/checkout@v4
1629

17-
- name: Setup just
18-
uses: extractions/setup-just@v2
19-
2030
- name: Install Posit Bakery
21-
uses: rstudio/posit-images-shared/setup-posit-bakery@main
31+
run: |
32+
gh auth login -p https --with-token <<< "${{ steps.app-token.outputs.token }}"
33+
gh auth setup-git
34+
pipx install 'git+https://github.com/posit-dev/images-shared.git@main#subdirectory=posit-bakery&egg=posit-bakery'
2235
2336
- name: Install goss and dgoss
24-
uses: rstudio/posit-images-shared/setup-goss@main
37+
uses: posit-dev/images-shared/setup-goss@main
2538

2639
- name: Set up Docker Buildx
2740
uses: docker/setup-buildx-action@v3
2841

29-
# TODO: replace with docker.io login in the future
30-
- name: Azure Container Registry Login
31-
uses: Azure/docker-login@v2
32-
with:
33-
login-server: '${{ secrets.ACR_REGISTRY }}'
34-
username: '${{ secrets.ACR_USERNAME }}'
35-
password: '${{ secrets.ACR_PASSWORD }}'
36-
37-
# TODO: remove once publishing to docker hub
38-
- name: Override registry
39-
run: echo -ne "variable \"registry\" {\n default = \"${{ secrets.ACR_REGISTRY }}\"\n}" > docker-bake.override.hcl
42+
- name: Setup just
43+
uses: extractions/setup-just@v2
4044

4145
- name: Build images
4246
env:
4347
GIT_SHA: ${{ github.sha }}
44-
run: bakery build --load
48+
run: |
49+
just download-pti
50+
bakery build --load
4551
4652
- name: Test images
47-
run: bakery dgoss
48-
49-
- name: Push images
50-
env:
51-
GIT_SHA: ${{ github.sha }}
52-
if: github.event_name == 'push'
53-
run: bakery build --push
53+
run: bakery run dgoss
54+
55+
# TODO: Reenable once we can use override repositories again
56+
# - name: Push images
57+
# env:
58+
# GIT_SHA: ${{ github.sha }}
59+
# if: github.event_name == 'push'
60+
# run: bakery build --push

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
tools/*goss
2-
docker-bake.override.hcl
1+
tools/*
2+
results/
3+
.docker-bake.json
34
.idea
45

56
### Python template

config.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#######################################################################################################################
2+
# BAKERY REPOSITORY CONFIG
3+
#
4+
# This file is used to define global properties for builds inside a repo managed by Posit's Bakery tool.
5+
#######################################################################################################################
6+
7+
# Define properties of the local repository. This information will be used when labeling image builds.
8+
[repository]
9+
url = "github.com/posit-dev/images-workbench"
10+
vendor = "Posit Software, PBC"
11+
maintainer = "docker@posit.co"
12+
authors = [
13+
"Ian H. Pittwood <ian.pittwood@posit.co>"
14+
]
15+
16+
# Define image registries used by builds in this repository. Images will be tagged appropriately for each registry.
17+
# Logins for private registries should be managed independently of Bakery.
18+
[[registries]]
19+
host = "docker.io"
20+
namespace = "posit"

docker-bake.hcl

Lines changed: 0 additions & 24 deletions
This file was deleted.

justfile

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#!/usr/bin/env just --justfile
22

3-
init-venv:
4-
#!/bin/bash
5-
set -ex
6-
rm -rf .venv
7-
python3 -m venv .venv
8-
9-
install-bakery:
3+
install-bakery *OPTS:
104
#!/bin/bash
115
# TODO: Update this after package is published somewhere
12-
{{justfile_directory()}}/.venv/bin/pip3 install https://saipittwood.blob.core.windows.net/packages/posit_bakery-0.1.0-py3-none-any.whl
6+
pipx install {{OPTS}} 'git+ssh://git@github.com/posit-dev/images-shared.git@main#egg=posit-bakery&subdirectory=posit-bakery'
137

148
install-goss:
159
#!/bin/bash
@@ -19,21 +13,42 @@ install-goss:
1913
curl -fsSL https://github.com/goss-org/goss/releases/latest/download/dgoss -o {{justfile_directory()}}/tools/dgoss
2014
chmod +rx {{justfile_directory()}}/tools/dgoss
2115

22-
init: init-venv install-bakery install-goss
16+
init: install-bakery install-goss
17+
18+
download-pti:
19+
#!/bin/bash
20+
set -eo pipefail
21+
22+
RELEASE_API_ENDPOINT="/repos/posit-dev/pti/releases/latest"
23+
GITHUB_TOKEN="${GITHUB_TOKEN:-$(gh auth token)}"
24+
25+
tag_name="$(gh --cache=1800s api $RELEASE_API_ENDPOINT --jq '.tag_name')"
26+
release_version="${tag_name#v}"
27+
assets="$(gh --cache=1800s api $RELEASE_API_ENDPOINT --jq '.assets.[] | [{name: .name, asset_url: .url}]')"
28+
29+
PROJECT_DIR="$(pwd)"
30+
PTI_DST_DIR="$(pwd)/pti_${release_version}"
31+
mkdir -p "${PTI_DST_DIR}"
32+
2333

24-
new product base_image="posit/base":
25-
{{ justfile_directory() }}/.venv/bin/bakery new "{{product}}" --context {{ justfile_directory() }} --image-base {{base_image}} --image-type "product"
34+
echo "$assets" | jq -c '.[]' | while read -r asset; do
35+
name=$(echo "$asset" | jq -r ".name")
36+
asset_url=$(echo "$asset" | jq -r ".asset_url")
2637

27-
alias generate := render
28-
render product version r_version python_version *OPTS:
29-
{{ justfile_directory() }}/.venv/bin/bakery render "{{product}}" "{{version}}" \
30-
--value r_version={{r_version}} \
31-
--value python_version={{python_version}} {{OPTS}}
38+
curl -sSL \
39+
-H 'Accept: application/octet-stream' \
40+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
41+
"${asset_url}" \
42+
-o "${PTI_DST_DIR}/${name}"
43+
done
3244

33-
alias bake := build
34-
build *OPTS:
35-
{{ justfile_directory() }}/.venv/bin/bakery build --context {{ justfile_directory() }} {{OPTS}}
45+
cd "${PTI_DST_DIR}"
46+
shasum -c pti*checksums.txt
47+
chmod +rx pti*linux_amd64
3648

37-
alias dgoss := test
38-
test *OPTS:
39-
{{ justfile_directory() }}/.venv/bin/bakery dgoss --context {{ justfile_directory() }} {{OPTS}}
49+
cd "$PROJECT_DIR"
50+
TOOLS_DIR="${PROJECT_DIR}/tools"
51+
mkdir -p "${TOOLS_DIR}"
52+
mv "${PTI_DST_DIR}/pti_linux_amd64" "${TOOLS_DIR}/pti"
53+
rm "${PTI_DST_DIR}/pti_checksums.txt"
54+
rmdir "${PTI_DST_DIR}"
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
ARG BASE_IMAGE_REGISTRY=docker.io
2-
FROM ${BASE_IMAGE_REGISTRY}/posit/base:ubuntu2204-min
3-
LABEL org.opencontainers.image.base.name="${BASE_IMAGE_REGISTRY}/posit/base:ubuntu2204-min"
1+
FROM --platform=linux/amd64 docker.io/library/ubuntu:22.04
2+
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:22.04"
43

54
### ARG declarations ###
65
ARG DEBIAN_FRONTEND=noninteractive
7-
ARG SCRIPTS_DIR=/opt/posit/scripts
6+
ARG PTI_VERSION="0.0.3"
7+
ARG PTI_NO_COLOR="true"
8+
ARG PTI_LOG_FORMAT="json"
9+
810
ARG WORKBENCH_VERSION="2024.04.2+764.pro1"
911
ARG RSTUDIO_INSTALL_NO_LICENSE_INITIALIZATION=1
1012

@@ -20,13 +22,28 @@ ENV DIAGNOSTIC_DIR /var/log/rstudio
2022
ENV DIAGNOSTIC_ENABLE false
2123
ENV DIAGNOSTIC_ONLY false
2224

25+
### Install Posit Tool Installer ###
26+
# FIXME(ianpittwood): Uncomment when PTI is available as a public repository
27+
#ADD --chmod=0755 \
28+
# https://github.com/posit-dev/pti/releases/download/v${PTI_VERSION}/pti_${PTI_VERSION}_linux_amd64 \
29+
# /usr/local/bin/pti
30+
# FIXME(ianpittwood): This is a shim to get around Github private repo authentication. ADD is a better solution once
31+
# pti is available publicly.
32+
COPY --chmod=0755 ./tools/pti /usr/local/bin/pti
33+
34+
### Initialize PTI in container ###
35+
RUN pti init
36+
2337
### Install System Packages ###
2438
COPY workbench/2024.04.2+764.pro1/deps/ubuntu2204_packages.txt /tmp/ubuntu2204_packages.txt
2539

26-
RUN $SCRIPTS_DIR/apt.sh --update upgrade \
27-
&& $SCRIPTS_DIR/apt.sh install $(cat /tmp/ubuntu2204_packages.txt) \
28-
&& rm -f /tmp/ubuntu2204_packages.txt \
29-
&& $SCRIPTS_DIR/apt.sh --clean
40+
RUN pti syspkg update \
41+
&& pti syspkg upgrade --dist \
42+
&& pti syspkg install -f /tmp/ubuntu2204_packages.txt \
43+
&& rm -f /tmp/ubuntu2204_packages.txt
44+
45+
### Install wait-for-it ###
46+
RUN pti container wait-for-it install
3047

3148
### Install Workbench 2024.04.2+764.pro1 ###
3249
COPY workbench/2024.04.2+764.pro1/scripts/install_workbench.sh /tmp/install_workbench.sh
@@ -35,14 +52,12 @@ RUN OS_URL=jammy /tmp/install_workbench.sh
3552
### Install Quarto to PATH ###
3653
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
3754

38-
39-
4055
### Copy startup scripts ###
41-
COPY --chmod=0775 workbench/2024.04.2+764.pro1/scripts/startup.sh /usr/local/bin/startup.sh
42-
COPY workbench/2024.04.2+764.pro1/startup/launcher /startup/launcher
43-
COPY workbench/2024.04.2+764.pro1/startup/base /startup/base
44-
COPY workbench/2024.04.2+764.pro1/startup/supervisord.conf /etc/supervisor/supervisord.conf
45-
COPY workbench/2024.04.2+764.pro1/conf/rstudio /etc/rstudio
56+
COPY --chmod=0775 "workbench/2024.04.2+764.pro1/scripts/startup.sh" /usr/local/bin/startup.sh
57+
COPY "workbench/2024.04.2+764.pro1/startup/launcher" /startup/launcher
58+
COPY "workbench/2024.04.2+764.pro1/startup/base" /startup/base
59+
COPY "workbench/2024.04.2+764.pro1/startup/supervisord.conf" /etc/supervisor/supervisord.conf
60+
COPY "workbench/2024.04.2+764.pro1/conf/jupyter/*" "workbench/2024.04.2+764.pro1/conf/launcher/*" "workbench/2024.04.2+764.pro1/conf/rstudio/*" "workbench/2024.04.2+764.pro1/conf/vscode/*" /etc/rstudio
4661

4762
### Configure Workbench ###
4863
RUN mkdir -p /var/lib/rstudio-server/monitor/log \
@@ -52,8 +67,6 @@ RUN mkdir -p /var/lib/rstudio-server/monitor/log \
5267
&& echo "RSPM=https://packagemanager.posit.co/cran/__linux__/jammy/latest" > /etc/rstudio/repos.conf \
5368
&& echo "CRAN=https://packagemanager.posit.co/cran/__linux__/jammy/latest" >> /etc/rstudio/repos.conf
5469

55-
56-
5770
EXPOSE 8787/tcp
5871
EXPOSE 5559/tcp
59-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
72+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
ARG BASE_IMAGE_REGISTRY=docker.io
2-
ARG PYTHON_VERSION="3.12.1"
3-
ARG R_VERSION="4.4.0"
4-
FROM ${BASE_IMAGE_REGISTRY}/posit/base:ubuntu2204
5-
LABEL org.opencontainers.image.base.name="${BASE_IMAGE_REGISTRY}/posit/base:ubuntu2204"
1+
FROM --platform=linux/amd64 docker.io/library/ubuntu:22.04
2+
LABEL org.opencontainers.image.base.name="docker.io/library/ubuntu:22.04"
63

74
### ARG declarations ###
85
ARG DEBIAN_FRONTEND=noninteractive
9-
ARG SCRIPTS_DIR=/opt/posit/scripts
6+
ARG PTI_VERSION="0.0.3"
7+
ARG PTI_NO_COLOR="true"
8+
ARG PTI_LOG_FORMAT="json"
9+
1010
ARG PYTHON_VERSION="3.12.1"
1111
ARG R_VERSION="4.4.0"
1212
ARG WORKBENCH_VERSION="2024.04.2+764.pro1"
@@ -24,37 +24,60 @@ ENV DIAGNOSTIC_DIR /var/log/rstudio
2424
ENV DIAGNOSTIC_ENABLE false
2525
ENV DIAGNOSTIC_ONLY false
2626

27+
### Install Posit Tool Installer ###
28+
# FIXME(ianpittwood): Uncomment when PTI is available as a public repository
29+
#ADD --chmod=0755 \
30+
# https://github.com/posit-dev/pti/releases/download/v${PTI_VERSION}/pti_${PTI_VERSION}_linux_amd64 \
31+
# /usr/local/bin/pti
32+
# FIXME(ianpittwood): This is a shim to get around Github private repo authentication. ADD is a better solution once
33+
# pti is available publicly.
34+
COPY --chmod=0755 ./tools/pti /usr/local/bin/pti
35+
36+
### Initialize PTI in container ###
37+
RUN pti init
38+
2739
### Install System Packages ###
2840
COPY workbench/2024.04.2+764.pro1/deps/ubuntu2204_packages.txt /tmp/ubuntu2204_packages.txt
2941
COPY workbench/2024.04.2+764.pro1/deps/ubuntu2204_optional_packages.txt /tmp/ubuntu2204_optional_packages.txt
30-
RUN $SCRIPTS_DIR/apt.sh --update upgrade \
31-
&& $SCRIPTS_DIR/apt.sh install $(cat /tmp/ubuntu2204_packages.txt) \
32-
&& rm -f /tmp/ubuntu2204_packages.txt \
33-
&& $SCRIPTS_DIR/apt.sh install $(cat /tmp/ubuntu2204_optional_packages.txt) \
42+
RUN pti syspkg update \
43+
&& pti syspkg upgrade --dist \
44+
&& pti syspkg install -f /tmp/ubuntu2204_packages.txt \
45+
&& pti syspkg install -f /tmp/ubuntu2204_optional_packages.txt \
3446
&& rm -f /tmp/ubuntu2204_optional_packages.txt \
35-
&& $SCRIPTS_DIR/apt.sh --clean
47+
&& rm -f /tmp/ubuntu2204_packages.txt
48+
49+
### Install wait-for-it ###
50+
RUN pti container wait-for-it install
3651

3752
### Install Workbench 2024.04.2+764.pro1 ###
3853
COPY workbench/2024.04.2+764.pro1/scripts/install_workbench.sh /tmp/install_workbench.sh
3954
RUN OS_URL=jammy /tmp/install_workbench.sh
4055

4156
### Install Quarto to PATH ###
4257
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
43-
4458
### Install TinyTeX using Quarto ###
45-
RUN $SCRIPTS_DIR/install_quarto.sh --install-tinytex --add-path-tinytex
59+
RUN pti quarto tinytex install --add-to-path
60+
61+
### Install R ###
62+
RUN pti r install --add-to-path --default "${R_VERSION}"
4663

47-
### Install Jupyter and extensions ###
48-
RUN $SCRIPTS_DIR/install_python.sh --install-jupyter --install-jupyter-kernel -- ${PYTHON_VERSION}
64+
### Install Python and Jupyter ###
65+
RUN pti python install --add-to-path --default "${PYTHON_VERSION}" \
66+
&& pti python jupyter install "${PYTHON_VERSION}" \
67+
&& ln -s /opt/python/jupyter/bin/jupyter /usr/local/bin/jupyter \
68+
&& pti python jupyter add-kernel "${PYTHON_VERSION}"
69+
70+
### Install Pro Drivers ###
71+
RUN pti pro-drivers install --copy-odbcinst
4972

5073
### Copy startup scripts ###
51-
COPY --chmod=0775 workbench/2024.04.2+764.pro1/scripts/startup.sh /usr/local/bin/startup.sh
52-
COPY workbench/2024.04.2+764.pro1/startup/launcher /startup/launcher
53-
COPY workbench/2024.04.2+764.pro1/startup/base /startup/base
54-
COPY workbench/2024.04.2+764.pro1/startup/supervisord.conf /etc/supervisor/supervisord.conf
55-
COPY workbench/2024.04.2+764.pro1/startup/user-provisioning /startup/user-provisioning
56-
COPY --chmod=600 workbench/2024.04.2+764.pro1/conf/sssd/sssd.conf /etc/sssd/sssd.conf
57-
COPY workbench/2024.04.2+764.pro1/conf/rstudio /etc/rstudio
74+
COPY --chmod=0775 "workbench/2024.04.2+764.pro1/scripts/startup.sh" /usr/local/bin/startup.sh
75+
COPY "workbench/2024.04.2+764.pro1/startup/launcher" /startup/launcher
76+
COPY "workbench/2024.04.2+764.pro1/startup/base" /startup/base
77+
COPY "workbench/2024.04.2+764.pro1/startup/supervisord.conf" /etc/supervisor/supervisord.conf
78+
COPY "workbench/2024.04.2+764.pro1/startup/user-provisioning" /startup/user-provisioning
79+
COPY --chmod=600 "workbench/2024.04.2+764.pro1/conf/sssd/sssd.conf" /etc/sssd/sssd.conf
80+
COPY "workbench/2024.04.2+764.pro1/conf/jupyter/*" "workbench/2024.04.2+764.pro1/conf/launcher/*" "workbench/2024.04.2+764.pro1/conf/rstudio/*" "workbench/2024.04.2+764.pro1/conf/vscode/*" /etc/rstudio
5881

5982
### Configure Workbench ###
6083
RUN mkdir -p /var/lib/rstudio-server/monitor/log \
@@ -63,10 +86,9 @@ RUN mkdir -p /var/lib/rstudio-server/monitor/log \
6386
&& printf '\n# allow home directory creation\nsession required pam_mkhomedir.so skel=/etc/skel umask=0077\n' >> /etc/pam.d/common-session \
6487
&& echo "RSPM=https://packagemanager.posit.co/cran/__linux__/jammy/latest" > /etc/rstudio/repos.conf \
6588
&& echo "CRAN=https://packagemanager.posit.co/cran/__linux__/jammy/latest" >> /etc/rstudio/repos.conf
66-
6789
LABEL co.posit.image.tools.python="3.12.1" \
6890
co.posit.image.tools.r="4.4.0"
6991

7092
EXPOSE 8787/tcp
7193
EXPOSE 5559/tcp
72-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
94+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
File renamed without changes.
File renamed without changes.

workbench/template/conf/rstudio/launcher.conf.jinja2 renamed to workbench/2024.04.2+764.pro1/conf/launcher/launcher.conf

File renamed without changes.

0 commit comments

Comments
 (0)