Simplify Lumier README

This commit is contained in:
f-trycua
2025-05-07 16:36:22 -07:00
parent 8d3e47ea79
commit c5df0a0240
6 changed files with 106 additions and 116 deletions

View File

@@ -22,3 +22,4 @@ venv/
test-results/
# Ignore anything else you don't want in the Docker build context
./examples

View File

@@ -30,10 +30,10 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
# Download and install noVNC without caching
RUN wget https://github.com/trycua/noVNC/archive/refs/heads/master.zip -O master.zip && \
unzip master.zip && \
RUN wget https://github.com/trycua/noVNC/archive/refs/heads/master.zip -O master1.zip && \
unzip master1.zip && \
mv noVNC-master /opt/noVNC && \
rm master.zip
rm master1.zip
# Set environment variables for noVNC
ENV NOVNC_PATH="/opt/noVNC"

View File

@@ -55,10 +55,7 @@ Here's what's happening behind the scenes:
# 1. Navigate to the Lumier directory
cd libs/lumier
# 2. Build the Docker image (first-time setup)
docker build -t lumier:latest .
# 3. Run the container with temporary storage
# 2. Run the container with temporary storage (using pre-built image from Docker Hub)
docker run -it --rm \
--name lumier-vm \
-p 8006:8006 \
@@ -66,7 +63,7 @@ docker run -it --rm \
-e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \
-e CPU_CORES=4 \
-e RAM_SIZE=8192 \
lumier:latest
trycua/lumier:latest
```
After running the command above, you can access your macOS VM through a web browser (e.g., http://localhost:8006).
@@ -91,7 +88,7 @@ docker run -it --rm \
-e CPU_CORES=4 \
-e RAM_SIZE=8192 \
-e HOST_STORAGE_PATH=$(pwd)/storage \
lumier:latest
trycua/lumier:latest
```
This command creates a connection between a folder on your Mac (`$(pwd)/storage`) and a folder inside the Docker container (`/storage`). The `-v` flag (volume mount) and the `HOST_STORAGE_PATH` variable work together to ensure your VM data is saved on your host Mac.
@@ -116,11 +113,96 @@ docker run -it --rm \
-e RAM_SIZE=8192 \
-e HOST_STORAGE_PATH=$(pwd)/storage \
-e HOST_SHARED_PATH=$(pwd)/shared \
lumier:latest
trycua/lumier:latest
```
With this setup, any files you place in the `shared` folder on your Mac will be accessible from within the macOS VM, and vice versa.
## Using Docker Compose
You can also use Docker Compose to run Lumier with a simple configuration file. Create a `docker-compose.yml` file with the following content:
```yaml
version: '3'
services:
lumier:
image: trycua/lumier:latest
container_name: lumier-vm
restart: unless-stopped
ports:
- "8006:8006" # Port for VNC access
volumes:
- ./storage:/storage # VM persistent storage
- ./shared:/shared # Shared folder accessible in the VM
environment:
- VM_NAME=lumier-vm
- VERSION=ghcr.io/trycua/macos-sequoia-cua:latest
- CPU_CORES=4
- RAM_SIZE=8192
- HOST_STORAGE_PATH=${PWD}/storage
- HOST_SHARED_PATH=${PWD}/shared
stop_signal: SIGINT
stop_grace_period: 2m
```
Then run Lumier using:
```bash
# First create the required directories
mkdir -p storage shared
# Start the container
docker-compose up -d
# View the logs
docker-compose logs -f
# Stop the container when done
docker-compose down
```
## Building and Customizing Lumier
If you want to customize the Lumier container or build it from source, you can follow these steps:
```bash
# 1. Navigate to the Lumier directory
cd libs/lumier
# 2. Build the Docker image locally
docker build -t lumier-custom:latest .
# 3. Run your custom build
docker run -it --rm \
--name lumier-vm \
-p 8006:8006 \
-e VM_NAME=lumier-vm \
-e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \
-e CPU_CORES=4 \
-e RAM_SIZE=8192 \
lumier-custom:latest
```
### Customization Options
The Dockerfile provides several customization points:
1. **Base image**: The container uses Debian Bullseye Slim as the base. You can modify this if needed.
2. **Installed packages**: You can add or remove packages in the apt-get install list.
3. **Hooks**: Check the `/run/hooks/` directory for scripts that run at specific points during VM lifecycle.
4. **Configuration**: Review `/run/config/constants.sh` for default settings.
After making your modifications, you can build and push your custom image to your own Docker Hub repository:
```bash
# Build with a custom tag
docker build -t yourusername/lumier:custom .
# Push to Docker Hub (after docker login)
docker push yourusername/lumier:custom
```
## Configuration Options
When running Lumier, you'll need to configure a few things:

View File

@@ -1,31 +0,0 @@
# Custom Lumier image that uses the base lumier:latest image
# and overrides environment variables as needed
FROM trycua/lumier:latest
# Default environment variables that can be overridden at build time
# These values will override the defaults from the base image
ARG CUSTOM_VERSION="ghcr.io/trycua/macos-sequoia-vanilla:latest"
ARG CUSTOM_RAM_SIZE="16384"
ARG CUSTOM_CPU_CORES="8"
ARG CUSTOM_DISK_SIZE="100"
ARG CUSTOM_DISPLAY="1024x768"
ARG CUSTOM_VM_NAME="custom-vanilla-lumier"
# Set environment variables based on build args
ENV VERSION=${CUSTOM_VERSION}
ENV RAM_SIZE=${CUSTOM_RAM_SIZE}
ENV CPU_CORES=${CUSTOM_CPU_CORES}
ENV DISK_SIZE=${CUSTOM_DISK_SIZE}
ENV DISPLAY=${CUSTOM_DISPLAY}
ENV VM_NAME=${CUSTOM_VM_NAME}
# Create the necessary directory for lifecycle scripts
RUN mkdir -p /run/lifecycle
# Copy custom on-logon script to be executed inside the VM after login
COPY src/lifecycle/on-logon.sh /run/lifecycle/on-logon.sh
# Make sure the script is executable
RUN chmod +x /run/lifecycle/on-logon.sh
# We're using the default entrypoint from the base image

View File

@@ -1,44 +0,0 @@
version: '3'
# IMPORTANT: Before using this docker-compose file, start the tunnel manually:
# socat TCP-LISTEN:8080,reuseaddr,fork EXEC:"$(pwd)/../src/bin/tunnel.sh" &
services:
lumier:
image: lumier:latest # or trycua/lumier:latest if using the Docker Hub image
container_name: lumier-vm
restart: unless-stopped
ports:
- "8006:8006" # Port for VNC access
volumes:
- ../storage:/storage # VM persistent storage (relative path from docker-compose.yml)
- ../shared:/data # Shared folder accessible in the VM
environment:
- VM_NAME=lumier-vm
- VERSION=ghcr.io/trycua/macos-sequoia-vanilla:latest # Default MacOS image
- CPU_CORES=4 # Number of CPU cores
- RAM_SIZE=8192 # RAM in MB
- HOST_STORAGE_PATH=${PWD}/../storage # Required for Docker-only setup
- HOST_SHARED_PATH=${PWD}/../shared # Required for Docker-only setup
- LUMIER_DEBUG=0 # Set to 1 for debug mode
# Network mode host is optional but can improve performance
# network_mode: host
# Uncomment the following lines if needed for KVM virtualization
# devices:
# - /dev/kvm
# - /dev/net/tun
stop_signal: SIGINT
stop_grace_period: 2m
# Note: When using Docker Compose for Lumier, you're responsible for:
# - Starting and managing the tunnel (using socat as shown above)
# - Building the Docker image before first use (docker-compose build)
# - Providing the correct environment variables (HOST_STORAGE_PATH and HOST_SHARED_PATH)
#
# To stop the tunnel when done:
# 1. Find the process: lsof -i TCP:8080
# 2. Kill it by PID: kill <PID>
#
# Access the VM via VNC at: http://localhost:8006/vnc.html
# The password will be displayed in the logs (docker-compose logs)

View File

@@ -31,14 +31,12 @@ if [ -z "${VM_NAME:-}" ]; then
export VM_NAME
fi
# Set HOST_STORAGE_PATH to a macOS ephemeral path if not set
# Set HOST_STORAGE_PATH to a lume ephemeral storage if not set
if [ -z "${HOST_STORAGE_PATH:-}" ]; then
# Use macOS /private/tmp directory which gets automatically cleaned
# This is the proper temporary directory on macOS that's regularly purged
HOST_STORAGE_PATH="/private/tmp/lumier_storage"
HOST_STORAGE_PATH="ephemeral"
# Tell user that ephemeral storage is being used
echo "Using ephemeral storage at ${HOST_STORAGE_PATH}. VM state will be lost when macOS cleans up temporary files."
echo "Using ephemeral storage. VM state will be lost when macOS cleans up temporary files."
export HOST_STORAGE_PATH
fi
@@ -56,6 +54,12 @@ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
# fi
fi
# Check if we're running as PID 1 (important for Docker signal handling)
if [ $$ -ne 1 ]; then
echo "Warning: This script is not running as PID 1 (current PID: $$)."
echo "Docker signal handling may not work properly when stopped from Docker Desktop."
fi
# Log startup info
echo "Lumier VM is starting..."
@@ -73,43 +77,21 @@ cleanup() {
fi
# Attempt to clean up ephemeral storage if it's in the /private/tmp directory
if [[ "$HOST_STORAGE_PATH" == "/private/tmp/lumier_"* ]]; then
echo "[cleanup] Checking if VM exists before cleanup..."
if [[ "$HOST_STORAGE_PATH" == "ephemeral" ]]; then
# First check if VM actually exists
VM_INFO=$(lume_get "$VM_NAME" "$HOST_STORAGE_PATH" "json" "false")
# Only try VM deletion if VM exists and not in the middle of a pull
if [[ "$PULL_IN_PROGRESS" != "1" && $VM_INFO != *"Virtual machine not found"* ]]; then
echo "[cleanup] Removing VM and storage using API: $HOST_STORAGE_PATH"
echo "[cleanup] Cleaning up VM..."
lume_delete "$VM_NAME" "$HOST_STORAGE_PATH" > /dev/null 2>&1
else
echo "[cleanup] No VM found or pull was interrupted, skipping API deletion"
fi
fi
# Now gently stop noVNC proxy if running
# if [ -n "${NOVNC_PID:-}" ] && kill -0 "$NOVNC_PID" 2>/dev/null; then
# echo "[cleanup] Stopping noVNC proxy (PID $NOVNC_PID)..."
# kill -TERM "$NOVNC_PID"
# # Wait up to 5s for noVNC to exit
# for i in {1..5}; do
# if ! kill -0 "$NOVNC_PID" 2>/dev/null; then
# echo "[cleanup] noVNC proxy stopped."
# break
# fi
# sleep 1
# done
# # Escalate if still running
# if kill -0 "$NOVNC_PID" 2>/dev/null; then
# echo "[cleanup] noVNC proxy did not exit, killing..."
# kill -KILL "$NOVNC_PID" 2>/dev/null
# fi
# fi
echo "[cleanup] Done. Exiting."
exit 0
}
trap cleanup SIGTERM SIGINT
# Ensure we catch all typical container termination signals
trap cleanup SIGTERM SIGINT SIGHUP
# Now enable strict error handling after initialization
set -euo pipefail