Skip to content

Commit f99f938

Browse files
committed
use pam-helper as auth, change to port 8080
1 parent c46e9ec commit f99f938

3 files changed

Lines changed: 58 additions & 49 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ RUN R -e "remotes::install_github('chris-mcginnis-ucsf/DoubletFinder@3b420df68b8
2525
COPY ./start-rserver.sh /usr/local/bin/start-rserver.sh
2626
RUN chmod +x /usr/local/bin/start-rserver.sh
2727

28-
EXPOSE 8787
28+
EXPOSE 8080
2929
CMD ["/usr/local/bin/start-rserver.sh"]

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,43 @@
88
5. Open a browser and run Rstudio
99

1010

11-
```
11+
```sh
1212
# On the HPC (from an interactive job or within a SLURM submission)
13-
#PORT=$(shuf -i 10000-20000 -n 1)
14-
PORT=13337
15-
echo "RStudio on $(hostname):$PORT"
16-
1713
apptainer run \
1814
--cleanenv \
19-
--env RSTUDIO_PORT=$PORT \
15+
--env RSTUDIO_PORT=8080 \
2016
--env RSTUDIO_ADDRESS=0.0.0.0 \
21-
docker://ghcr.io/karlssonlaboratory/rstudio-server:latest
17+
docker://ghcr.io/karlssonlaboratory/rstudio-server:c46e9ec > ~/rserver.log 2>&1
2218
```
2319

2420
```
25-
#ssh -N -L 8787:<compute-node>:$PORT <remote-host>
26-
# open http://localhost:8787
21+
ssh -v -N -L 8080:p108:8080 pelle
22+
# open http://localhost:9876
2723
```
2824

2925

3026
```
31-
ghcr.io/karlssonlaboratory/rstudio-server:latest
27+
ghcr.io/karlssonlaboratory/rstudio-server:c46e9ec
28+
```
29+
30+
```sh
31+
# On the HPC (from an interactive job or within a SLURM submission)
32+
mkdir -p test_dir/marimo_test
33+
cd test_dir/marimo_test
34+
35+
ml pixi-tools
36+
37+
pixi init -c conda-forge -c bioconda
38+
pixi add python
39+
pixi add --pypi marimo
40+
pixi shell
41+
marimo edit --headless --host 0.0.0.0 --port 8080
42+
```
43+
44+
```sh
45+
ssh -L 8080:p108:8080 pelle
46+
```
47+
48+
```sh
49+
http://0.0.0.0:8080
3250
```

start-rserver.sh

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
PORT="${RSTUDIO_PORT:-8787}"
4+
PORT="${RSTUDIO_PORT:-8080}"
55
ADDRESS="${RSTUDIO_ADDRESS:-0.0.0.0}"
6+
USER_NAME="$(id -un)"
7+
WORKDIR="${RSTUDIO_TMPDIR:-$HOME/.rstudio-server-run}"
68

7-
if [ "$(id -u)" -eq 0 ]; then
8-
# --- Docker path: running as root, use rocker's built-in init ---
9-
# rocker/rstudio ships /init which sets up the rstudio user and launches rserver.
10-
# Honor a password if provided, otherwise disable auth (only safe behind a tunnel).
11-
export PASSWORD="${PASSWORD:-}"
12-
if [ -z "$PASSWORD" ]; then
13-
export DISABLE_AUTH=true
14-
fi
15-
exec /init
9+
mkdir -p "$WORKDIR"/{run,lib,log,tmp}
1610

17-
else
18-
# --- Apptainer path: rootless, everything must live under $HOME ---
19-
USER_NAME="$(id -un)"
20-
USER_ID="$(id -u)"
21-
WORKDIR="${RSTUDIO_TMPDIR:-$HOME/.rstudio-server-run}"
22-
mkdir -p "$WORKDIR"/{run,lib,log,tmp}
23-
24-
COOKIE_KEY="$WORKDIR/secure-cookie-key"
25-
if [ ! -s "$COOKIE_KEY" ]; then
26-
uuidgen > "$COOKIE_KEY"
27-
chmod 0600 "$COOKIE_KEY"
28-
fi
11+
# Generate a password if not supplied
12+
if [ -z "${PASSWORD:-}" ]; then
13+
PASSWORD=$(openssl rand -base64 15)
14+
echo "=================================================="
15+
echo "RStudio login:"
16+
echo " User: $USER_NAME"
17+
echo " Password: $PASSWORD"
18+
echo "=================================================="
19+
fi
20+
export PASSWORD
2921

30-
cat > "$WORKDIR/database.conf" <<EOF
22+
# rserver wants this in a .conf file too
23+
cat > "$WORKDIR/database.conf" <<EOF
3124
provider=sqlite
3225
directory=$WORKDIR/lib
3326
EOF
3427

35-
cat > "$WORKDIR/rserver.conf" <<EOF
36-
www-port=$PORT
37-
www-address=$ADDRESS
38-
www-verify-user-agent=0
39-
auth-none=1
40-
auth-minimum-user-id=$USER_ID
41-
server-user=$USER_NAME
42-
server-data-dir=$WORKDIR/run
43-
secure-cookie-key-file=$COOKIE_KEY
44-
database-config-file=$WORKDIR/database.conf
45-
server-daemonize=0
46-
EOF
47-
48-
exec /usr/lib/rstudio-server/bin/rserver --config-file="$WORKDIR/rserver.conf"
49-
fi
28+
exec /usr/lib/rstudio-server/bin/rserver \
29+
--www-port="$PORT" \
30+
--www-address="$ADDRESS" \
31+
--www-verify-user-agent=0 \
32+
--auth-none=0 \
33+
--auth-pam-helper-path=pam-helper \
34+
--auth-stay-signed-in-days=30 \
35+
--auth-timeout-minutes=0 \
36+
--server-user="$USER_NAME" \
37+
--server-data-dir="$WORKDIR/run" \
38+
--database-config-file="$WORKDIR/database.conf" \
39+
--secure-cookie-key-file="$WORKDIR/secure-cookie-key" \
40+
--server-daemonize=0

0 commit comments

Comments
 (0)