# Wiki.js Knowledge Base

> Modern wiki platform with Wiki.js, Git sync, and full-text search.

- Category: Productivity & Collaboration
- Difficulty: intermediate
- Components: wikijs, postgresql, elasticsearch
- Tags: wikijs, wiki, knowledge-base, documentation, markdown
- Source: https://docker.recipes/productivity/wiki-js-complete

## Overview

Wiki.js is a modern, lightweight wiki engine built on Node.js that revolutionizes knowledge management with its Git-native approach to content versioning and sleek, responsive interface. Originally created by Nicolas Giard in 2017, Wiki.js addresses the limitations of traditional wiki platforms by offering native Markdown support, extensive authentication integrations, and powerful search capabilities while maintaining simplicity for content creators. This production stack combines Wiki.js with PostgreSQL for robust relational data storage and Elasticsearch for enterprise-grade full-text search functionality. PostgreSQL serves as the primary database, storing user accounts, page metadata, and configuration data with ACID compliance, while Elasticsearch indexes all wiki content to provide lightning-fast search results with relevance scoring and advanced query capabilities. The synergy between these components creates a knowledge base platform that scales from small team documentation to enterprise-wide knowledge repositories. This configuration is ideal for organizations that need professional documentation management with Git workflow integration, teams requiring advanced search across large content volumes, and businesses wanting to migrate from legacy wiki platforms while maintaining data integrity and search performance.

## Features

- Native Git synchronization for content versioning and backup with support for GitHub, GitLab, and Bitbucket repositories
- Advanced full-text search powered by Elasticsearch with relevance scoring, faceted search, and content highlighting
- WYSIWYG and Markdown editors with real-time preview and collaborative editing capabilities
- PostgreSQL JSONB storage for flexible page metadata and custom field management
- Multi-authentication support including LDAP, SAML, OAuth2, and local authentication with role-based access control
- Elasticsearch aggregations for content analytics including page views, search trends, and user activity metrics
- Automated page tree management with PostgreSQL hierarchical queries for complex documentation structures
- Real-time content indexing with Elasticsearch bulk operations for immediate search availability

## Use cases

- Software development teams needing technical documentation with Git workflow integration and code snippet management
- Enterprise organizations migrating from Confluence or SharePoint while maintaining advanced search capabilities
- Educational institutions creating searchable knowledge bases for course materials and research documentation
- Customer support teams building comprehensive help centers with fast content retrieval and user feedback tracking
- Open source projects requiring collaborative documentation with public access and contributor management
- IT departments creating internal runbooks and procedures with role-based access and audit trails
- Consulting firms managing client documentation with project-based access control and content versioning

## Prerequisites

- Minimum 4GB RAM available (2GB for Elasticsearch, 1GB for PostgreSQL, 1GB for Wiki.js and system overhead)
- Docker and Docker Compose installed with support for named volumes and custom networks
- Port 3000 available for Wiki.js web interface access
- Basic understanding of PostgreSQL administration for backup and maintenance procedures
- Git repository access if planning to use Git synchronization features for content versioning
- SSL certificate and reverse proxy knowledge for production HTTPS deployment

## docker-compose.yml

```yaml
services:
  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=wiki
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=wiki
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - wiki_net

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.15
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - es_data:/usr/share/elasticsearch/data
    networks:
      - wiki_net

  wiki:
    image: ghcr.io/requarks/wiki:2
    ports:
      - "3000:3000"
    environment:
      - DB_TYPE=postgres
      - DB_HOST=postgres
      - DB_PORT=5432
      - DB_USER=wiki
      - DB_PASS=${POSTGRES_PASSWORD}
      - DB_NAME=wiki
    depends_on:
      - postgres
      - elasticsearch
    networks:
      - wiki_net

volumes:
  postgres_data:
  es_data:

networks:
  wiki_net:
```

## .env

```bash
# Wiki.js
POSTGRES_PASSWORD=secure_postgres_password

# Wiki.js at http://localhost:3000
# Complete setup wizard on first access
```

## Usage notes

- Wiki.js at http://localhost:3000
- Complete setup wizard first
- Git storage for version control
- Elasticsearch for full-text search
- Multiple auth providers

## Troubleshooting

- Wiki.js shows 'Database connection failed': Verify POSTGRES_PASSWORD environment variable matches between postgres and wiki services, and ensure postgres container is fully started before wiki container attempts connection
- Elasticsearch container exits with 'max virtual memory areas vm.max_map_count too low': Run 'sysctl -w vm.max_map_count=262144' on Docker host and add 'vm.max_map_count=262144' to /etc/sysctl.conf for persistence
- Search functionality returns no results: Check Elasticsearch container logs for indexing errors and verify ES_JAVA_OPTS memory allocation doesn't exceed available container memory
- Wiki.js setup wizard shows database error: Ensure PostgreSQL container has completed initialization by checking logs for 'database system is ready to accept connections' message before accessing Wiki.js
- High memory usage from Elasticsearch: Reduce ES_JAVA_OPTS heap size from 512m to 256m for smaller deployments, but expect slower search performance with large content volumes

