mirror of
https://github.com/stellarshenson/stellars-jupyterhub-ds.git
synced 2026-03-07 13:40:28 +00:00
chore: updated with the new way of localhost routing
This commit is contained in:
13
extra/traefik-host-based-routing/.env.default
Normal file
13
extra/traefik-host-based-routing/.env.default
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default environment variables for JupyterHub deployment
|
||||
# Override in .env (not tracked by git)
|
||||
|
||||
# Domain for Traefik routing
|
||||
# Example: lab.example.com
|
||||
BASE_HOSTNAME=localhost
|
||||
|
||||
# JupyterHub subdomain prefix (set empty to serve at root domain)
|
||||
JUPYTERHUB_PREFIX=jupyterhub.
|
||||
|
||||
# Enable CIFS mount for shared storage (0=disabled, 1=enabled)
|
||||
# Requires compose_cifs.yml to be configured with NAS credentials
|
||||
ENABLE_CIFS=0
|
||||
@@ -1,13 +0,0 @@
|
||||
# Environment variables for JupyterHub deployment
|
||||
# Copy to .env and customize
|
||||
|
||||
# Domain for Traefik routing (required)
|
||||
# Example: lab.example.com
|
||||
BASE_HOSTNAME=localhost
|
||||
|
||||
# JupyterHub hostname (remove jupyterhub. prefix to serve at root domain)
|
||||
JUPYTERHUB_HOSTNAME=jupyterhub.${BASE_HOSTNAME}
|
||||
|
||||
# Enable CIFS mount for shared storage (0=disabled, 1=enabled)
|
||||
# Requires compose_cifs.yml to be configured with NAS credentials
|
||||
ENABLE_CIFS=0
|
||||
@@ -12,13 +12,13 @@ Template for deploying stellars-jupyterhub-ds with local Traefik reverse proxy a
|
||||
|
||||
2. Generate certificates for your domain:
|
||||
```bash
|
||||
./generate-certs.sh yourdomain.example.com
|
||||
./generate-certs.sh --cn "My DEV Certificate" --dns-altnames "*.example.com,example.com,*.localhost,localhost"
|
||||
```
|
||||
|
||||
3. Create `.env` and set your hostname:
|
||||
3. Configure (optional):
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# Edit .env: BASE_HOSTNAME=yourdomain.example.com
|
||||
# Create .env to override defaults from .env.default:
|
||||
echo "BASE_HOSTNAME=example.com" > .env
|
||||
```
|
||||
|
||||
4. Start:
|
||||
@@ -34,13 +34,14 @@ Template for deploying stellars-jupyterhub-ds with local Traefik reverse proxy a
|
||||
compose_cifs.yml # Optional CIFS mount configuration
|
||||
start.sh # Clone/update + start services
|
||||
stop.sh # Stop services
|
||||
generate-certs.sh # Certificate generation script
|
||||
generate-certs.sh # Certificate generation (--help for usage)
|
||||
install_cert.sh # Linux certificate installer
|
||||
install_cert.bat # Windows certificate installer
|
||||
.env.example # Example environment config
|
||||
.env.default # Default environment config (always loaded)
|
||||
.env # Local overrides (optional, gitignored)
|
||||
certs/
|
||||
tls.yml # Traefik TLS configuration
|
||||
_.yourdomain.example.com/ # Generated wildcard cert
|
||||
<prefix>.tls.yml # Traefik TLS configuration (auto-generated)
|
||||
<prefix>/ # Certificate folder (auto-generated)
|
||||
cert.pem # Certificate (import to browser)
|
||||
key.pem # Private key
|
||||
stellars-jupyterhub-ds/ # Cloned repository (gitignored)
|
||||
@@ -48,27 +49,25 @@ Template for deploying stellars-jupyterhub-ds with local Traefik reverse proxy a
|
||||
|
||||
## Configuration
|
||||
|
||||
Set `BASE_HOSTNAME` in `.env` for your domain. Edit `compose_override.yml` to customize:
|
||||
- Ports (default: 80/443)
|
||||
- Environment variables (idle culler, signup)
|
||||
- Network name
|
||||
Configure via `.env.default` (always loaded) and `.env` (optional overrides, gitignored):
|
||||
|
||||
- `BASE_HOSTNAME` - domain for Traefik routing (default: `localhost`)
|
||||
- `JUPYTERHUB_PREFIX` - JupyterHub subdomain prefix, set empty to serve at root domain (default: `jupyterhub.`)
|
||||
- `ENABLE_CIFS` - enable CIFS shared mount, `0`/`1` (default: `0`)
|
||||
|
||||
Edit `compose_override.yml` to customize ports (default: 80/443), environment variables (idle culler, signup), or network name.
|
||||
|
||||
### Optional CIFS Mount
|
||||
|
||||
To enable shared NAS storage for user containers:
|
||||
|
||||
1. Edit `compose_cifs.yml` with your NAS credentials
|
||||
2. Create `.env` from `.env.example`:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
3. Set `ENABLE_CIFS=1` in `.env`
|
||||
2. Set `ENABLE_CIFS=1` in `.env`
|
||||
|
||||
## Access
|
||||
|
||||
After deployment:
|
||||
- JupyterHub: https://jupyterhub.yourdomain.example.com/
|
||||
- Traefik: https://traefik.yourdomain.example.com
|
||||
- JupyterHub: `https://${JUPYTERHUB_PREFIX}${BASE_HOSTNAME}/` (default: `jupyterhub.localhost`)
|
||||
- Traefik: `https://traefik.${BASE_HOSTNAME}/`
|
||||
- Localhost: `https://jupyterhub.localhost/`, `https://jupyterhub.app.localhost/`
|
||||
|
||||
### Certificate Installation
|
||||
|
||||
@@ -76,12 +75,12 @@ Import the self-signed certificate to your browser for trusted HTTPS:
|
||||
|
||||
**Linux:**
|
||||
```bash
|
||||
./install_cert.sh certs/_.yourdomain.example.com/
|
||||
./install_cert.sh certs/<prefix>/
|
||||
```
|
||||
|
||||
**Windows:**
|
||||
```cmd
|
||||
install_cert.bat certs\_.yourdomain.example.com\
|
||||
install_cert.bat certs\<prefix>\
|
||||
```
|
||||
|
||||
## Commands
|
||||
@@ -94,5 +93,5 @@ install_cert.bat certs\_.yourdomain.example.com\
|
||||
|
||||
To view logs:
|
||||
```bash
|
||||
docker compose -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml logs -f jupyterhub
|
||||
docker compose --env-file .env.default -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml logs -f jupyterhub
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ services:
|
||||
- "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true"
|
||||
|
||||
# Dashboard: traefik.${BASE_HOSTNAME}
|
||||
- "traefik.http.routers.dashboard.rule=Host(`traefik.${BASE_HOSTNAME}`) || Host(`traefik.localhost`)"
|
||||
- "traefik.http.routers.dashboard.rule=Host(`traefik.${BASE_HOSTNAME}`) || HostRegexp(`^traefik(\\..+)?\\.localhost$`)"
|
||||
- "traefik.http.routers.dashboard.entrypoints=websecure"
|
||||
- "traefik.http.routers.dashboard.tls=true"
|
||||
- "traefik.http.routers.dashboard.service=api@internal"
|
||||
@@ -75,7 +75,7 @@ services:
|
||||
- "traefik.enable=true"
|
||||
|
||||
# JupyterHub router (root path)
|
||||
- "traefik.http.routers.jupyterhub-rtr.rule=Host(`${JUPYTERHUB_HOSTNAME}`) || Host(`jupyterhub.localhost`)"
|
||||
- "traefik.http.routers.jupyterhub-rtr.rule=Host(`${JUPYTERHUB_PREFIX}${BASE_HOSTNAME}`) || HostRegexp(`^${JUPYTERHUB_PREFIX}(.*\\.)?localhost$`)"
|
||||
- "traefik.http.routers.jupyterhub-rtr.entrypoints=websecure"
|
||||
- "traefik.http.routers.jupyterhub-rtr.tls=true"
|
||||
- "traefik.http.routers.jupyterhub-rtr.service=jupyterhub-svc"
|
||||
|
||||
@@ -10,16 +10,8 @@ REPO_URL="https://github.com/stellarshenson/stellars-jupyterhub-ds.git"
|
||||
REPO_DIR="stellars-jupyterhub-ds"
|
||||
REFRESH=false
|
||||
|
||||
# Default configuration (override via .env)
|
||||
ENABLE_CIFS="${ENABLE_CIFS:-0}"
|
||||
|
||||
# Create .env from example if missing
|
||||
if [[ ! -f .env ]] && [[ -f .env.example ]]; then
|
||||
cp .env.example .env
|
||||
echo "Created .env from .env.example"
|
||||
fi
|
||||
|
||||
# Load environment variables
|
||||
# Load defaults, then local overrides
|
||||
source .env.default
|
||||
if [[ -f .env ]]; then
|
||||
source .env
|
||||
fi
|
||||
@@ -53,7 +45,11 @@ else
|
||||
fi
|
||||
|
||||
# Build compose command with optional CIFS mount
|
||||
COMPOSE_FILES="--env-file .env -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml"
|
||||
COMPOSE_FILES="--env-file .env.default"
|
||||
if [[ -f .env ]]; then
|
||||
COMPOSE_FILES="${COMPOSE_FILES} --env-file .env"
|
||||
fi
|
||||
COMPOSE_FILES="${COMPOSE_FILES} -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml"
|
||||
if [[ "${ENABLE_CIFS}" == "1" ]]; then
|
||||
echo "CIFS mount enabled"
|
||||
COMPOSE_FILES="${COMPOSE_FILES} -f compose_cifs.yml"
|
||||
@@ -64,4 +60,4 @@ docker compose ${COMPOSE_FILES} pull
|
||||
docker pull stellars/stellars-jupyterlab-ds:latest
|
||||
docker compose ${COMPOSE_FILES} up -d --no-build
|
||||
|
||||
echo "Done. Access: https://${JUPYTERHUB_HOSTNAME:-localhost}/"
|
||||
echo "Done. Access: https://${JUPYTERHUB_PREFIX:-jupyterhub.}${BASE_HOSTNAME:-localhost}/"
|
||||
|
||||
@@ -5,22 +5,18 @@ set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Default configuration (override via .env)
|
||||
ENABLE_CIFS="${ENABLE_CIFS:-0}"
|
||||
|
||||
# Create .env from example if missing
|
||||
if [[ ! -f .env ]] && [[ -f .env.example ]]; then
|
||||
cp .env.example .env
|
||||
echo "Created .env from .env.example"
|
||||
fi
|
||||
|
||||
# Load environment variables
|
||||
# Load defaults, then local overrides
|
||||
source .env.default
|
||||
if [[ -f .env ]]; then
|
||||
source .env
|
||||
fi
|
||||
|
||||
# Build compose command with optional CIFS mount
|
||||
COMPOSE_FILES="--env-file .env -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml"
|
||||
COMPOSE_FILES="--env-file .env.default"
|
||||
if [[ -f .env ]]; then
|
||||
COMPOSE_FILES="${COMPOSE_FILES} --env-file .env"
|
||||
fi
|
||||
COMPOSE_FILES="${COMPOSE_FILES} -f stellars-jupyterhub-ds/compose.yml -f compose_override.yml"
|
||||
if [[ "${ENABLE_CIFS}" == "1" ]]; then
|
||||
COMPOSE_FILES="${COMPOSE_FILES} -f compose_cifs.yml"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user