Initial commit

This commit is contained in:
Aodhan Collins
2025-09-08 01:03:45 +01:00
commit a2adb89d93
5 changed files with 340 additions and 0 deletions

13
.env Normal file
View File

@@ -0,0 +1,13 @@
# Database Configuration
# Generate a secure password for your database
# You can use: openssl rand -base64 32
DB_PASSWORD=your_secure_database_password_here
# Wiki.js Configuration
# The domain where your wiki will be accessible
# For local development, use localhost:3000
# For production, use your actual domain
WIKI_URL=http://localhost:3000
# Optional: Set timezone (default is UTC)
TZ=Europe/London

155
README.md Normal file
View File

@@ -0,0 +1,155 @@
# Personal Wiki.js Setup for Home Server
This repository contains everything you need to set up your personal Wiki.js instance on your home server.
## 🚀 Quick Start
1. **Run the setup script:**
```bash
./setup.sh
```
2. **Access your wiki:**
- Open http://localhost:3000 in your browser
- Complete the initial setup wizard
- Create your administrator account
## 📁 Project Structure
```
wikiaodh/
├── docker-compose.yml # Docker services configuration
├── .env # Environment variables (passwords, etc.)
├── setup.sh # Automated setup script
├── README.md # This file
└── data/ # Created automatically for persistent data
├── wiki/ # Wiki application data
├── db/ # PostgreSQL database files
└── assets/ # Uploaded media and assets
```
## 🔧 Configuration
### Environment Variables (.env)
- `DB_PASSWORD`: Secure password for PostgreSQL database
- `WIKI_URL`: The URL where your wiki will be accessible
- `TZ`: Your timezone (default: Europe/London)
### Ports
- **3000**: Wiki.js web interface (http://localhost:3000)
- **5432**: PostgreSQL database (internal only)
## 📋 Management Commands
```bash
# Start the wiki
docker-compose up -d
# Stop the wiki
docker-compose down
# View logs
docker-compose logs -f
# Restart services
docker-compose restart
# Update to latest version
docker-compose pull
docker-compose up -d
```
## 💾 Backup & Restore
### Backup
```bash
# Backup database
docker-compose exec db pg_dump -U wikijs wiki > backup_$(date +%Y%m%d).sql
# Backup uploaded files
tar -czf assets_backup_$(date +%Y%m%d).tar.gz data/assets/
```
### Restore
```bash
# Restore database
docker-compose exec -T db psql -U wikijs wiki < backup_YYYYMMDD.sql
# Restore uploaded files
tar -xzf assets_backup_YYYYMMDD.tar.gz
```
## 🔒 Security Considerations
1. **Change default passwords**: The setup script generates a secure database password automatically
2. **Firewall**: Consider restricting access to port 3000 to your local network only
3. **HTTPS**: For production use, set up a reverse proxy with SSL/TLS
4. **Regular updates**: Keep Docker images updated with `docker-compose pull`
## 🌐 Accessing from Other Devices
To access your wiki from other devices on your network:
1. Find your server's IP address: `ip addr show`
2. Update the `WIKI_URL` in `.env` to use your server's IP
3. Access via `http://YOUR_SERVER_IP:3000`
## 📚 Wiki.js Features
Your personal wiki includes:
- **Rich Text Editor**: WYSIWYG and Markdown support
- **Media Management**: Upload and organize images, documents, videos
- **Search**: Full-text search across all content
- **User Management**: Create accounts for family members or team
- **Themes**: Light and dark mode support
- **Mobile Friendly**: Responsive design for all devices
- **Version History**: Track changes to all pages
- **Categories & Tags**: Organize content efficiently
## 🆘 Troubleshooting
### Wiki won't start
```bash
# Check logs
docker-compose logs
# Restart services
docker-compose down
docker-compose up -d
```
### Database connection issues
```bash
# Reset database
docker-compose down
docker volume rm wikiaodh_db-data
docker-compose up -d
```
### Permission issues
```bash
# Fix permissions
sudo chown -R $USER:$USER data/
chmod -R 755 data/
```
## 🔄 Updates
To update Wiki.js to the latest version:
```bash
docker-compose down
docker-compose pull
docker-compose up -d
```
## 📞 Support
- [Wiki.js Documentation](https://docs.js.wiki/)
- [Wiki.js GitHub](https://github.com/Requarks/wiki)
- [Docker Compose Documentation](https://docs.docker.com/compose/)
---
**Enjoy your personal wiki! 📖✨**

44
backup.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Wiki.js Backup Script
# Creates backups of your wiki database and uploaded assets
set -e
BACKUP_DIR="backups"
DATE=$(date +%Y%m%d_%H%M%S)
echo "🔄 Starting Wiki.js backup..."
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# Check if services are running
if ! docker-compose ps | grep -q "Up"; then
echo "❌ Wiki.js services are not running. Please start them first with: docker-compose up -d"
exit 1
fi
echo "💾 Backing up database..."
# Backup PostgreSQL database
docker-compose exec -T db pg_dump -U wikijs wiki > "$BACKUP_DIR/wiki_db_$DATE.sql"
echo "📁 Backing up assets and data..."
# Backup uploaded assets and wiki data
tar -czf "$BACKUP_DIR/wiki_assets_$DATE.tar.gz" -C data assets wiki 2>/dev/null || true
# Backup configuration files
echo "⚙️ Backing up configuration..."
tar -czf "$BACKUP_DIR/wiki_config_$DATE.tar.gz" docker-compose.yml .env README.md 2>/dev/null || true
echo "✅ Backup completed successfully!"
echo "📂 Backup files created:"
echo " - Database: $BACKUP_DIR/wiki_db_$DATE.sql"
echo " - Assets: $BACKUP_DIR/wiki_assets_$DATE.tar.gz"
echo " - Config: $BACKUP_DIR/wiki_config_$DATE.tar.gz"
# Clean up old backups (keep last 7 days)
echo "🧹 Cleaning up old backups (keeping last 7 days)..."
find "$BACKUP_DIR" -name "wiki_*" -type f -mtime +7 -delete 2>/dev/null || true
echo "🎉 Backup process complete!"

49
docker-compose.yml Normal file
View File

@@ -0,0 +1,49 @@
version: '3.8'
services:
wiki:
image: ghcr.io/requarks/wiki:2
container_name: wikiaodh
depends_on:
- db
environment:
DB_TYPE: postgres
DB_HOST: db
DB_PORT: 5432
DB_USER: wikijs
DB_PASS: ${DB_PASSWORD}
DB_NAME: wiki
UPGRADE_COMPANION: 1
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- wiki-data:/wiki/data
- wiki-assets:/wiki/assets
networks:
- wiki-network
db:
image: postgres:15-alpine
container_name: wikiaodh-db
environment:
POSTGRES_DB: wiki
POSTGRES_USER: wikijs
POSTGRES_PASSWORD: ${DB_PASSWORD}
restart: unless-stopped
volumes:
- db-data:/var/lib/postgresql/data
networks:
- wiki-network
volumes:
wiki-data:
driver: local
wiki-assets:
driver: local
db-data:
driver: local
networks:
wiki-network:
driver: bridge

79
setup.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
# Wiki.js Setup Script for Home Server
# This script helps you set up your personal Wiki.js instance
set -e
echo "🚀 Setting up Wiki.js for your home server..."
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
echo "Visit: https://docs.docker.com/engine/install/"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
echo "Visit: https://docs.docker.com/compose/install/"
exit 1
fi
# Generate a secure database password if not already set
if [ ! -f .env ]; then
echo "❌ .env file not found. Please create it first."
exit 1
fi
# Check if password is still the default
if grep -q "your_secure_database_password_here" .env; then
echo "🔐 Generating secure database password..."
SECURE_PASSWORD=$(openssl rand -base64 32)
sed -i "s/your_secure_database_password_here/$SECURE_PASSWORD/g" .env
echo "✅ Secure password generated and saved to .env"
fi
# Create necessary directories
echo "📁 Creating data directories..."
mkdir -p data/wiki
mkdir -p data/db
mkdir -p data/assets
# Set proper permissions
echo "🔧 Setting permissions..."
chmod 755 data/wiki data/db data/assets
# Pull the latest images
echo "📥 Pulling Docker images..."
docker-compose pull
# Start the services
echo "🏃 Starting Wiki.js services..."
docker-compose up -d
# Wait for services to be ready
echo "⏳ Waiting for services to start..."
sleep 10
# Check if services are running
if docker-compose ps | grep -q "Up"; then
echo "✅ Wiki.js is starting up!"
echo ""
echo "🌐 Your wiki will be available at: http://localhost:3000"
echo "⏰ Please wait 1-2 minutes for the initial setup to complete."
echo ""
echo "📋 Next steps:"
echo "1. Open http://localhost:3000 in your browser"
echo "2. Complete the initial setup wizard"
echo "3. Create your administrator account"
echo "4. Start adding content to your personal wiki!"
echo ""
echo "📊 To check status: docker-compose logs -f"
echo "🛑 To stop: docker-compose down"
echo "🔄 To restart: docker-compose restart"
else
echo "❌ Something went wrong. Check the logs with: docker-compose logs"
exit 1
fi