Skip to content

Commit

Permalink
Release customization
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyzt committed Apr 24, 2024
1 parent 683409a commit aeb6c3a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ FROM quay.io/jupyter/$STACK_BASE:$STACK_VERSION
# Set-up environment
# ==================

ENV DESI_RELEASE=edr

# Slight customization to Bash
# https://docs.docker.com/develop/develop-images/instructions/#using-pipes
# This fails commands even if errors occur before a pipe
Expand All @@ -42,9 +40,6 @@ ENV HOME=/home
ENV DESI_BUCKET=$HOME/desibucket
ENV DESI_BUCKET_CACHE=$HOME/.desibucket_cache

# For compatibility with NERSC, $DESI_ROOT points to the base of the latest public data release
ENV DESI_ROOT=$DESI_BUCKET/$DESI_RELEASE

# Some NERSC tutorials use this hard-coded path instead, which we symlink
ENV DESI_NERSC=/global/cfs/cdirs/desi
ENV DESI_BUCKET_NERSC=$DESI_NERSC/public
Expand Down
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Open your computer's terminal.

If your DESI data is locally hosted at `local_data_path`, then enter this command:
```bash
docker run -it -p 8888:8888 \
docker run -it -p 8888:8888 -e DESI_RELEASE=edr \
--volume "$(pwd):/home/synced" \
--volume "local_data_path:/home/desibucket:ro" \
ghcr.io/flyorboom/docker-aws-jupyter:main
Expand All @@ -50,7 +50,7 @@ docker run -it -p 8888:8888 \

Otherwise, to access the DESI data hosted at AWS S3, then enter this command instead:
```bash
docker run -it -p 8888:8888 \
docker run -it -p 8888:8888 -e DESI_RELEASE=edr \
--volume "$(pwd):/home/synced" \
--cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined \
ghcr.io/flyorboom/docker-aws-jupyter:main
Expand Down Expand Up @@ -149,7 +149,7 @@ sudo systemctl start docker.service

In the terminal, run this shell command to download and run the image.
```bash
docker run -it -p 8888:8888 \
docker run -it -p 8888:8888 -e DESI_RELEASE=edr \
--volume "$(pwd):/home/synced" \
--cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined \
ghcr.io/flyorboom/docker-aws-jupyter:main
Expand All @@ -158,6 +158,21 @@ docker run -it -p 8888:8888 \
Once the image starts running, locate the line beginning with `http://127.0.0.1:8888/lab?token=...` in the output.
Replace `127.0.0.1` with the public IP address of your cloud server, then open the modified link in your browser.

## Customizations

* The internal and external ports of the Jupyter server are respectively the first and second `8888` in `-p 8888:8888`.
Adjust these (as well as the port security policy if using EC2) should you have port collision issues.
* To point `$DESI_ROOT` to another public data release,
replace `edr` with the other release's name in the `-e DESI_RELEASE=edr` flag.
* To sync your changes in the container to a custom local folder,
replace `$(pwd)` (which points to the folder where you entered the `docker run` command)
with the absolute path to the custom folder.
* To build the image yourself, enter the command
`` bash
docker build github.com/flyorboom/docker-aws-jupyter.git --tag desi-aws
```
Then, simply replace the tag `ghcr.io/flyorboom/docker-aws-jupyter:main` with `desi-aws` when running the image.
## Updating the Docker image
To update your Docker image, run
Expand Down
16 changes: 14 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,29 @@ echo "
-----------------------------------------------------------------------|
"

# Set release to latest public release (edr), unless user-specified at runtime.
# The ,, forces lowercase.

if [ -z "$DESI_RELEASE" ]; then
export DESI_RELEASE=edr
fi
DESI_RELEASE=${DESI_RELEASE,,}
echo "+ Set \$DESI_ROOT to the $DESI_RELEASE release."
export DESI_ROOT=$DESI_BUCKET/$DESI_RELEASE

# If $DESI_BUCKET is not already occupied (by a local mount),
# then mount AWS S3 bucket to $DESI_BUCKET, with cache at $DESI_BUCKET_CACHE.

if [ "$(ls -A $DESI_BUCKET)" ]; then
echo "Mounted local DESI data directory."
echo "+ Mounted local DESI data directory."
else
echo "+ Mounting remote DESI data directory..."
mount-s3 \
--cache $DESI_BUCKET_CACHE \
--region us-west-2 \
--read-only \
--no-sign-request \
desiproto $DESI_BUCKET
echo "Mounted remote DESI data directory."
fi

# Add DESI Python libraries to PATH and PYTHONPATH
Expand All @@ -48,6 +58,8 @@ export PYTHONPATH=$DESI_HUB/specsim:$PYTHONPATH
# Start the Jupyter server
# (https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile)

echo "+ Starting Jupyter..."
echo ""
/usr/local/bin/start.sh start-notebook.py

# Unmount when done
Expand Down

0 comments on commit aeb6c3a

Please sign in to comment.