Last active
          February 20, 2020 15:52 
        
      - 
      
- 
        Save austinsonger/e28350534bcefad23b0296dc36391403 to your computer and use it in GitHub Desktop. 
    WikiJS - ubuntu 18.04
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # | |
| # Wikijs Install With Docker on Ubuntu 18.04 | |
| # | |
| ############################################### | |
| sudo apt -qqy update | |
| # Install all updates automatically | |
| echo "[1/1] Installing all updates automatically..." | |
| sleep 1 | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade | |
| # Install dependencies to install Docker | |
| echo "[2/11] Installing dependencies to install Docker..." | |
| sleep 1 | |
| sudo apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install apt-transport-https ca-certificates curl gnupg-agent software-properties-common openssl | |
| # Register Docker package registry | |
| echo "[3/11] Registering Docker package registry..." | |
| sleep 1 | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
| sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
| # Refresh package udpates and install Docker | |
| echo "[4/11] Refreshing package udpates and install Docker..." | |
| sleep 1 | |
| sudo apt -qqy update | |
| sudo apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install docker-ce docker-ce-cli containerd.io | |
| # Create installation directory for Wiki.js | |
| echo "[5/11] Creating installation directory for Wiki.js..." | |
| sleep 1 | |
| mkdir -p /etc/wiki | |
| # Generate DB secret | |
| echo "[6/11] Generating DB secret..." | |
| sleep 1 | |
| openssl rand -base64 32 > /etc/wiki/.db-secret | |
| # Create internal docker network | |
| echo "[7/11] Creating internal docker network..." | |
| sleep 1 | |
| docker network create wikinet | |
| # Create data volume for PostgreSQL | |
| echo "[8/11] Creating data volume for PostgreSQL..." | |
| sleep 1 | |
| docker volume create pgdata | |
| # Create the containers | |
| echo "[9/11] Creating the containers..." | |
| sleep 1 | |
| docker create --name=db -e POSTGRES_DB=wiki -e POSTGRES_USER=wiki -e POSTGRES_PASSWORD_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -v pgdata:/var/lib/postgresql/data --restart=unless-stopped -h db --network=wikinet postgres:11 | |
| docker create --name=wiki -e DB_TYPE=postgres -e DB_HOST=db -e DB_PORT=5432 -e DB_PASS_FILE=/etc/wiki/.db-secret -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro -e DB_USER=wiki -e DB_NAME=wiki -e UPGRADE_COMPANION=1 --restart=unless-stopped -h wiki --network=wikinet -p 80:3000 -p 443:3443 requarks/wiki:2 | |
| docker create --name=wiki-update-companion -v /var/run/docker.sock:/var/run/docker.sock:ro --restart=unless-stopped -h wiki-update-companion --network=wikinet requarks/wiki-update-companion:latest | |
| # Configuring Firewall | |
| echo "[10/11] Configuring Firewall..." | |
| sleep 1 | |
| sudo ufw allow ssh | |
| sudo ufw allow http | |
| sudo ufw allow https | |
| sudo ufw --force enable | |
| # Starting Docker | |
| echo "[11/11] Starting Docker..." | |
| sleep 5 | |
| docker start db | |
| docker start wiki | |
| docker start wiki-update-companion | |
| echo -e "-> ${green}Wikijs Installation Complete${normal}\n" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment