Skip to content

Commit 7ac645b

Browse files
committed
WB CLI and AoU env variables
1 parent bb9779d commit 7ac645b

5 files changed

Lines changed: 40 additions & 37 deletions

File tree

src/aou-sas/.devcontainer.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,7 @@
55
"runServices": ["app", "wondershaper"],
66
"shutdownAction": "none",
77
"workspaceFolder": "/workspace",
8-
"postCreateCommand": [
9-
"./startupscript/post-startup.sh",
10-
"aou",
11-
"/data",
12-
"${templateOption:cloud}",
13-
"${templateOption:login}"
14-
],
15-
"postStartCommand": [
16-
"./startupscript/remount-on-restart.sh",
17-
"aou",
18-
"/data",
19-
"${templateOption:cloud}",
20-
"${templateOption:login}"
21-
],
8+
"postCreateCommand": "./startupscript/post-startup.sh aou /data ${templateOption:cloud} ${templateOption:login} && ./setup-sas-env.sh aou /data",
9+
"postStartCommand": "./startupscript/remount-on-restart.sh aou /data ${templateOption:cloud} ${templateOption:login} && ./setup-sas-env.sh aou /data",
2210
"remoteUser": "root"
2311
}

src/aou-sas/Dockerfile

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ USER root
66
# This must be in the Dockerfile because it references a build context (load-envs).
77
COPY --from=load-envs /dist/load-env /dist/load-env.sh /opt/sas/aou/
88

9-
###############################################################################
10-
# Package-manager compatibility
11-
# Workbench startup scripts (post-startup.sh, resource-mount.sh) expect
12-
# apt-get / apt. These shims delegate to yum on this RHEL-based SAS image.
13-
###############################################################################
14-
RUN printf '#!/bin/bash\ncase "$1" in\n update) exec yum makecache -y ;;\n install) shift; exec yum install -y --allowerasing "$@" ;;\n *) exec yum "$@" ;;\nesac\n' > /usr/local/bin/apt-get && \
15-
chmod +x /usr/local/bin/apt-get && \
16-
cp /usr/local/bin/apt-get /usr/local/bin/apt && \
17-
chmod +x /usr/local/bin/apt
18-
199
###############################################################################
2010
# Disable SAS-internal repos (unreachable outside SAS network) and enable
2111
# public UBI + EPEL repos so packages like jq, fuse, git can be resolved.
@@ -26,22 +16,14 @@ RUN dnf config-manager --set-disabled \
2616
sas-ubi-9-baseos sas-ubi-9-appstream sas-ubi-9-codeready-builder && \
2717
dnf config-manager --set-enabled \
2818
ubi-9-baseos-rpms ubi-9-appstream-rpms ubi-9-codeready-builder-rpms && \
29-
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
30-
yum clean all
19+
dnf clean all
3120

3221
###############################################################################
3322
# System packages required by Workbench startup scripts
3423
###############################################################################
35-
RUN yum install -y --allowerasing curl fuse fuse-libs wget sudo git \
24+
RUN dnf install -y --allowerasing curl fuse fuse-libs wget sudo git \
3625
java-17-openjdk-headless && \
37-
yum clean all
38-
39-
###############################################################################
40-
# gcsfuse — GCS bucket mounting
41-
###############################################################################
42-
RUN printf '[gcsfuse]\nname=gcsfuse (packages.cloud.google.com)\nbaseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=0\ngpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg\n https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\n' > /etc/yum.repos.d/gcsfuse.repo && \
43-
yum install -y gcsfuse && \
44-
yum clean all
26+
dnf clean all
4527

4628
###############################################################################
4729
# Google Cloud SDK
@@ -66,6 +48,10 @@ RUN groupadd -g 1100 aougroup && \
6648
###############################################################################
6749
RUN echo "-work /data/saswork" >> /opt/sas/viya/config/etc/workspaceserver/default/sasv9_usermods.cfg && \
6850
echo "-utilloc /data/utilloc" >> /opt/sas/viya/config/etc/workspaceserver/default/sasv9_usermods.cfg && \
51+
echo 'if [ -f /data/.aou-env ]; then source /data/.aou-env; fi' >> \
52+
/opt/sas/viya/config/etc/workspaceserver/default/workspaceserver_usermods.sh && \
53+
echo 'if [ -f /data/.workbench-env ]; then source /data/.workbench-env; fi' >> \
54+
/opt/sas/viya/config/etc/workspaceserver/default/workspaceserver_usermods.sh && \
6955
sed -Ei 's#^USERMODS=(.*)#USERMODS=-allowxcmd \1#g' \
7056
/opt/sas/viya/config/etc/spawner/default/spawner_usermods.sh
7157

@@ -87,6 +73,11 @@ RUN PROXY_CONF=/etc/httpd/conf.d/dkrapro-proxy.conf && \
8773
sed -i '/AOU-CONFIGURED/a Header unset Content-Security-Policy' "${PROXY_CONF}" && \
8874
sed -i '/AOU-CONFIGURED/a Header edit Set-Cookie "^(.*SameSite=None.*)\$" "\$1; Secure"' "${PROXY_CONF}"
8975

76+
###############################################################################
77+
# Create /data directory and chown to AoU user
78+
###############################################################################
79+
RUN mkdir -p /data && chown aou:aougroup /data
80+
9081
# Wrapper entrypoint: copies the SAS license from Mikey Secrets (if active)
9182
# to /sasinside/ before handing off to the SAS entrypoint.
9283
COPY --from=wb-secret-receiver /dist/wb-secret-receiver /wb-secret-receiver

src/aou-sas/sas-pre-deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ chown -R aou:aougroup /data
2323
if [ -d /opt/sas/aou ]; then
2424
cp -n /opt/sas/aou/load-env /opt/sas/aou/load-env.sh /data/ 2>/dev/null || true
2525
chown aou:aougroup /data/load-env /data/load-env.sh 2>/dev/null || true
26-
grep -q "load-env.sh" /data/.bashrc 2>/dev/null || \
27-
echo "source /data/load-env.sh" >> /data/.bashrc
26+
#grep -q "load-env.sh" /data/.bashrc 2>/dev/null || \
27+
# echo "source /data/load-env.sh" >> /data/.bashrc
2828
fi

src/aou-sas/setup-sas-env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# setup-sas-env.sh — Populate environment files for SAS Studio sessions.
3+
#
4+
# Runs after post-startup.sh (or remount-on-restart.sh) to create env files
5+
# that the SAS workspace server sources on session start.
6+
#
7+
# - /data/.aou-env: AoU CDR variables (from load-env)
8+
# - /data/.workbench-env: Workbench variables (extracted from .bashrc)
9+
10+
set -o errexit
11+
set -o nounset
12+
set -o pipefail
13+
14+
readonly USER_NAME="${1}"
15+
readonly DATA_DIR="${2}"
16+
17+
if [ -f "${DATA_DIR}/load-env.sh" ]; then
18+
sudo -u "${USER_NAME}" bash -c "source '${DATA_DIR}/load-env.sh'" || true
19+
fi
20+
21+
# Extract export statements from .bashrc to get workbench environment variables
22+
grep '^export ' "${DATA_DIR}/.bashrc" > "${DATA_DIR}/.workbench-env" || true

startupscript/install-cli.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ if ! command -v "${WORKBENCH_INSTALL_PATH}" &> /dev/null; then
6666

6767
${RUN_AS_LOGIN_USER} "curl -L https://storage.googleapis.com/${CLI_DISTRIBUTION_PATH#gs://}/download-install.sh | WORKBENCH_CLI_VERSION=${CLI_VERSION} bash"
6868
cp wb "${WORKBENCH_INSTALL_PATH}"
69+
chmod 755 "${WORKBENCH_INSTALL_PATH}"
6970

7071
# Copy 'wb' to its legacy 'terra' name.
7172
cp wb "${WORKBENCH_LEGACY_PATH}"
73+
chmod 755 "${WORKBENCH_LEGACY_PATH}"
7274
fi
7375

7476
# Set browser manual login since that's the only login supported from a Vertex AI Notebook VM

0 commit comments

Comments
 (0)