Customization¶
How to tailor DataSci Homelab to your preferences.
Configuration Hierarchy¶
DataSci Homelab uses a layered configuration approach:
- Base image — Default packages and settings baked into the Docker image
- Config overrides — Mounted files that override defaults without rebuilding
- Environment variables — Runtime configuration via
.env - User preferences — Settings saved in persistent volumes
Environment Variables¶
All configurable via .env:
Authentication¶
# RStudio credentials
RSTUDIO_USER=rstudio
RSTUDIO_PASSWORD=your-secure-password
# Jupyter token
JUPYTER_TOKEN=your-secure-token
# Disable auth entirely (not recommended)
DISABLE_AUTH=false
Ports¶
Image Selection¶
RStudio Preferences¶
How Preferences Work¶
RStudio preferences are stored in:
This file is in your home directory volume, so changes persist.
Repository-Tracked Preferences¶
To apply the same preferences on every deployment:
Location: config-overrides/rstudio-config/rstudio-prefs.json
This file is copied to the user's config directory on container startup.
Updating Preferences¶
- Change settings in RStudio (Tools → Global Options)
- Copy to the repo:
cp volumes/home/.config/rstudio/rstudio-prefs.json \
config-overrides/rstudio-config/
git add config-overrides/rstudio-config/rstudio-prefs.json
git commit -m "Update RStudio preferences"
Current Default Preferences¶
{
"editor_keybindings": "vim",
"editor_theme": "Xcode",
"font_size_points": 13,
"server_editor_font": "SF Mono",
"relative_line_numbers": true,
"rainbow_parentheses": true,
"reformat_on_save": true,
"use_air_formatter": true,
"auto_save_on_blur": true,
"save_workspace": "never",
"load_workspace": false,
"restore_source_documents": false
}
Common Customizations¶
Available themes: Ambiance, Chaos, Chrome, Clouds, Cobalt, Crimson Editor, Dawn, Dracula, Dreamweaver, Eclipse, Idle Fingers, Katzenmilch, Kr Theme, Material, Merbivore, Merbivore Soft, Mono Industrial, Monokai, Pastel On Dark, Solarized Dark, Solarized Light, TextMate, Tomorrow, Tomorrow Night, Tomorrow Night Blue, Tomorrow Night Bright, Tomorrow Night Eighties, Twilight, Vibrant Ink, Xcode
JupyterLab Settings¶
Accessing Settings¶
Settings → Settings Editor
Or edit directly:
Common Settings¶
Settings → Theme → JupyterLab Dark
Settings → Settings Editor → Text Editor → Font Size
Settings → Settings Editor → Document Manager → Auto Save Interval
Adding Packages to Base Image¶
For packages you always want available:
R Packages¶
Edit config/packages.R:
# Add to the appropriate category
viz_pkgs <- c(
"ggthemes",
"wesanderson",
"your-new-package" # Add here
)
Python Packages¶
Edit config/requirements.txt:
Then rebuild:
Server Configuration¶
RStudio Server¶
File: config-overrides/rserver.conf
# Server settings
www-address=0.0.0.0
www-port=8787
auth-none=0
auth-minimum-user-id=0
# Session settings
session-timeout-minutes=60
# Resource limits
limit-cpu-time-minutes=0
limit-file-upload-size-mb=1024
Jupyter Server¶
File: config-overrides/jupyter_server_config.py
c.ServerApp.ip = '0.0.0.0'
c.ServerApp.port = 8888
c.ServerApp.allow_origin = '*'
c.ServerApp.open_browser = False
Volume Customization¶
Using External Volumes¶
# docker-compose.override.yml
services:
homelab:
volumes:
# Mount external data
- /path/to/external/data:/data
# Use named volumes
- r-packages:/usr/local/lib/R/site-library
volumes:
r-packages:
external: true
Separate Home Directories¶
If you want separate home directories for RStudio and Jupyter:
# docker-compose.override.yml
services:
homelab:
volumes:
- ./volumes/rstudio-home:/home/rstudio
- ./volumes/jupyter-home:/home/jupyter
Adding System Dependencies¶
For R/Python packages that need system libraries:
Method 1: Runtime Installation¶
docker-compose exec -u root homelab apt-get update
docker-compose exec -u root homelab apt-get install -y libsomething-dev
Warning
Changes are lost on container recreation.
Method 2: Custom Dockerfile¶
# Dockerfile.custom
FROM ghcr.io/shawntz/datasci-homelab:latest
USER root
RUN apt-get update && apt-get install -y \
libsomething-dev \
another-package \
&& rm -rf /var/lib/apt/lists/*
USER rstudio
Timezone Configuration¶
Default timezone is America/Los_Angeles. To change:
Method 1: Environment Variable¶
Method 2: Rebuild Image¶
Edit the Dockerfile:
Custom Startup Scripts¶
Adding Initialization Steps¶
Create a custom entrypoint script:
# config-overrides/custom-init.sh
#!/bin/bash
# Your custom initialization
echo "Running custom init..."
# Call the original entrypoint
exec /entrypoint-override.sh "$@"
Update docker-compose.yml:
R Configuration¶
Global R Profile¶
File: /usr/lib/R/etc/Rprofile.site (in image)
Or add to ~/.Rprofile (persists in volume):
# Custom options
options(
repos = c(CRAN = "https://cloud.r-project.org"),
download.file.method = "libcurl",
Ncpus = parallel::detectCores(),
width = 120,
scipen = 999
)
# Load packages silently
suppressPackageStartupMessages({
library(tidyverse)
})
# Custom prompt
options(prompt = "R> ")
Environment Variables for R¶
Python Configuration¶
pip Configuration¶
File: ~/.config/pip/pip.conf
Python Startup¶
File: ~/.pythonrc
import pandas as pd
import numpy as np
pd.set_option('display.max_columns', 50)
pd.set_option('display.width', 120)
Then set:
Creating Your Own Base Image¶
For heavily customized setups:
# Dockerfile.custom
FROM ghcr.io/shawntz/datasci-homelab:latest
# Add your customizations
USER root
# System packages
RUN apt-get update && apt-get install -y \
your-package \
&& rm -rf /var/lib/apt/lists/*
# R packages
RUN Rscript -e "install.packages('your-package')"
# Python packages
RUN pip install your-package
USER rstudio
Build and use:
Update docker-compose.yml to use your image: