Skip to content

Commit 18e871e

Browse files
committed
fix: fix jupyterlab permission
1 parent 94a4529 commit 18e871e

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

tutorial/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
- PUID=1000
99
- PGID=1000
1010
- TZ=Etc/UTC
11+
- DEFAULT_WORKSPACE=/config/workspace
1112
# TODO: remember define these in .env file
1213
- PASSWORD
1314
- SUDO_PASSWORD_HASH
Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,59 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
rm -f ${HOME}/.jupyter/jupyter_lab_config.py
4+
# create new demo user for jupyterlab
5+
useradd -d /config/demo -g abc -G users demo
56

6-
s6-setuidgid abc \
7+
mkdir -p /config/.local/share
8+
chown abc:abc /config/.local/share
9+
chmod 775 /config/.local/share
10+
11+
mkdir -p /data
12+
chown abc:abc /data
13+
14+
SOURCE="/config/workspace"
15+
DEST="/config/demo"
16+
17+
if [ ! -d "${DEST}" ]; then
18+
mkdir -p "${DEST}"
19+
20+
EXCLUDE=(
21+
"assets"
22+
"tutorial"
23+
"work"
24+
)
25+
declare -A EXCLUDE_MAP=()
26+
for ex in "${EXCLUDE[@]}"; do
27+
EXCLUDE_MAP["$ex"]=1
28+
done
29+
30+
for entry in "$SOURCE"/*; do
31+
[ -e "$entry" ] || continue
32+
33+
name="$(basename "$entry")"
34+
35+
if [[ -n "${EXCLUDE_MAP[$name]:-}" ]]; then
36+
continue
37+
fi
38+
39+
cp -a --reflink=auto "$entry" "$DEST/"
40+
done
41+
42+
chown demo:abc -R "${DEST}"
43+
fi
44+
45+
rm -f /config/demo/.jupyter/jupyter_lab_config.py
46+
47+
sudo -u demo \
748
jupyter-lab --generate-config
849

950
# allow remote access
10-
echo "c.ServerApp.ip = '0.0.0.0'" >> ${HOME}/.jupyter/jupyter_lab_config.py
11-
echo "c.ServerApp.open_browser = False" >> ${HOME}/.jupyter/jupyter_lab_config.py
12-
echo "c.ServerApp.port = 8888" >> ${HOME}/.jupyter/jupyter_lab_config.py
13-
echo "c.ServerApp.allow_remote_access = True" >> ${HOME}/.jupyter/jupyter_lab_config.py
51+
echo "c.ServerApp.ip = '0.0.0.0'" >> /config/demo/.jupyter/jupyter_lab_config.py
52+
echo "c.ServerApp.open_browser = False" >> /config/demo/.jupyter/jupyter_lab_config.py
53+
echo "c.ServerApp.port = 8888" >> /config/demo/.jupyter/jupyter_lab_config.py
54+
echo "c.ServerApp.allow_remote_access = True" >> /config/demo/.jupyter/jupyter_lab_config.py
1455

1556
# set password if provided
1657
if [ -n "${JUPYTER_PASSWORD_HASH}" ]; then
17-
echo "c.PasswordIdentityProvider.hashed_password = u'${JUPYTER_PASSWORD_HASH}'" >> ${HOME}/.jupyter/jupyter_lab_config.py
58+
echo "c.PasswordIdentityProvider.hashed_password = u'${JUPYTER_PASSWORD_HASH}'" >> /config/demo/.jupyter/jupyter_lab_config.py
1859
fi
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
s6-setuidgid abc \
4+
s6-setuidgid demo \
55
jupyter-lab \
6-
--config=${HOME}/.jupyter/jupyter_lab_config.py \
7-
--notebook-dir=/config/workspace
6+
--config=/config/demo/.jupyter/jupyter_lab_config.py \
7+
--notebook-dir=/config/demo

0 commit comments

Comments
 (0)