-
-
Notifications
You must be signed in to change notification settings - Fork 3
environment variables
This document describes all environment variables used in the teXt0wnz project.
These variables are used during the build process and are read from the .env file in the project root.
Default: https://text.0w.nz
Purpose: Sets the domain for robots.txt and sitemap.xml generation.
Usage:
VITE_DOMAIN='https://your-domain.com'Note: This only affects SEO files. The application itself uses relative URLs and works on any domain.
Build files affected:
-
dist/robots.txt- Sets the sitemap location -
dist/sitemap.xml- Uses domain for URL generation
Default: ui/
Purpose: Sets the directory name for UI assets in the build output.
Usage:
VITE_UI_DIR='assets/'Build output structure:
dist/
βββ index.html
βββ {VITE_UI_DIR}/
βββ js/
βββ img/
βββ fonts/
βββ stylez.css
Note: Should end with / (or it will be added automatically). Leading slash is removed.
Default: websocket.js
Purpose: Sets the filename for the WebSocket worker.
Usage:
VITE_WORKER_FILE='worker.js'Note: This file is not hashed for cache-busting to allow service worker caching.
Default: fonts/
Purpose: Sets the directory name for bitmap font assets.
Usage:
VITE_FONT_DIR='bitmapfonts/'Note: Not used in vite.config.js but used in the frontend client application. See /src/js/client/state.js#L89
These variables are used when running the collaboration server.
Default: 1337
Purpose: Sets the port for the WebSocket collaboration server.
Usage:
# Command line
bun server 8060
# Environment variable
PORT=8060 bun server
# Docker
docker run -e PORT=8060 text0wnz:latestDefault: production
Purpose: Sets the Node.js environment mode.
Values:
-
production- Production mode with optimizations -
development- Development mode with verbose logging
Usage:
NODE_ENV=development bun server
# Docker
docker run -e NODE_ENV=development text0wnz:latestEffects:
- Logging verbosity
- Error messages
- Caddy configuration (in Docker)
- SSL settings (in Docker)
Default: localhost
Purpose: Sets the domain name for the server (Docker only).
Usage:
# Docker
docker run -e DOMAIN=text.example.com text0wnz:latestEffects (Docker):
- Caddy server configuration
- SSL certificate generation
- WebSocket endpoint configuration
Default: supersecretkey (auto-generated in Docker if not provided)
Purpose: Secret key for express-session middleware.
Usage:
# Docker
KEY=$(openssl rand -base64 32)
docker run -e SESSION_KEY=$KEY text0wnz:latestSecurity:
- Should be a long random string in production
- Used for session cookie signing
- Auto-generated via urandom in Docker if not provided
SESSION_KEY=$(tr -dc 'a-z0-9' </dev/urandom | head -c 20)Default: /var/lib/caddy (Docker only)
Purpose: Sets the Caddy data directory.
Usage:
# Docker
docker run -e XDG_DATA_HOME=/custom/path text0wnz:latestDefault: /etc/caddy (Docker only)
Purpose: Sets the Caddy configuration directory.
Usage:
# Docker
docker run -e XDG_CONFIG_HOME=/custom/path text0wnz:latestThese are GitHub secrets and environment variables used in workflows.
Purpose: Authentication for GitHub API operations.
Used in:
- All workflows for repository access
- Docker image pushes to GHCR
- Artifact uploads/downloads
- Pages deployment
Required: Yes (for docker-build.yml)
Purpose: Docker Hub login username.
Setup:
Repository Settings β Secrets and variables β Actions β New repository secret
Name: DOCKERHUB_USERNAME
Value: your-dockerhub-username
Required: Yes (for docker-build.yml)
Purpose: Docker Hub access token (password).
Setup:
1. Create access token at https://hub.docker.com/settings/security
2. Add to GitHub:
Repository Settings β Secrets and variables β Actions β New repository secret
Name: DOCKERHUB_TOKEN
Value: your-access-token
Required: Yes (for wiki.yml)
Purpose: Personal access token for wiki repository access.
Setup:
1. Create personal access token at https://github.com/settings/tokens
Required permissions: repo (full control)
2. Add to GitHub:
Repository Settings β Secrets and variables β Actions β New repository secret
Name: CICD_TOKEN
Value: your-personal-access-token
Required: Yes (for ci-docker-build.yml)
Purpose: Personal access token for GitHub Packages.
Setup:
1. Create personal access token at https://github.com/settings/tokens
Required permissions: write:packages, read:packages
2. Add to GitHub:
Repository Settings β Secrets and variables β Actions β New repository secret
Name: PKG_TOKEN
Value: your-personal-access-token
The .env file in the project root is used for local development configuration.
Example .env:
# Build configuration
VITE_DOMAIN='https://text.0w.nz'
VITE_UI_DIR='ui/'
VITE_FONT_DIR='fonts/'
VITE_WORKER_FILE='websocket.js'
# Server configuration (optional, can use CLI args instead)
PORT=1337
NODE_ENV=productionNote: The .env file is gitignored. Manually run: git add .env to track changes as needed.
Option 1: .env file (recommended)
# Create .env file
cat > .env << EOF
VITE_DOMAIN='https://localhost'
NODE_ENV=development
EOF
# Run build or server
bun bake
bun serverOption 2: Command line
# Inline
VITE_DOMAIN='https://localhost' bun bake
NODE_ENV=development bun server
# Export (for current shell session)
export VITE_DOMAIN='https://localhost'
export NODE_ENV=development
bun bake
bun serverOption 1: -e flags
docker run \
-e DOMAIN=your.domain.com \
-e NODE_ENV=production \
-e SESSION_KEY=your-secret-key \
text0wnz:latestOption 2: --env-file
# Create docker.env file
cat > docker.env << EOF
DOMAIN=your.domain.com
NODE_ENV=production
SESSION_KEY=your-secret-key
EOF
# Run with env file
docker run --env-file docker.env text0wnz:latestOption 3: docker-compose.yml
version: '3.8'
services:
text0wnz:
image: text0wnz:latest
environment:
- DOMAIN=your.cool.tld
- NODE_ENV=production
- SESSION_KEY=your-secret-key
ports:
- '80:80'
- '443:443'Environment variables are set in workflow files:
jobs:
build:
runs-on: ubuntu-latest
env:
NODE_ENV: production
steps:
- name: Build
run: bun bake
env:
VITE_DOMAIN: ${{ secrets.CUSTOM_DOMAIN }}Build-time variables not applied:
- Ensure
.envfile exists in project root - Variable names must start with
VITE_ - Rebuild application after changing variables
Runtime variables not working:
- Check environment variable is exported
- Verify variable name (case-sensitive)
- Check Docker logs for environment values
Issue: Sitemap has wrong domain
Solution: Set VITE_DOMAIN in .env before building
Issue: WebSocket connection fails in Docker
Solution: Set DOMAIN environment variable to match your domain
Note: The default for no domain or port set is ws://localhost:1337
Issue: Session errors in Docker
Solution: Set SESSION_KEY to a secure random value in your docker run command
-
Never commit
.envfile - It's gitignored for security -
Use strong SESSION_KEY - Generate with:
openssl rand -base64 32 - Rotate secrets regularly - Update Docker/CI secrets periodically
- Limit token permissions - Give minimum required permissions
- Use environment-specific configs - Different keys for dev/staging/prod
- Building and Developing - Build process and configuration
- Docker - Container deployment and environment setup
- CI/CD Pipeline - Workflow configuration and secrets
- Collaboration Server - Server configuration options