# BookStack

Installation Guide for Internal Services

# BookStack Installation Guide

This Guide goes trough steps necessary for creating a good well organized step by step process. This guide walks you through deploying BookStack using Docker and Docker Compose, with a working configuration that includes MariaDB, proper environment variables, and SSL disabled for local development.

[BoookStack Installation Documentation](https://www.bookstackapp.com/docs/admin/installation/)

[GitHub Repository](https://github.com/linuxserver/docker-bookstack)

##### Prerequisites

- Docker and Docker Compose installed
- Portainer or terminal access

##### Steps

These steps are for terminal access

1. Create Project Directory

```
mkdir ~/bookstack-docker
cd ~/bookstack-docker
```

2. Generate Larvel app Key

```bash
docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey
```

3. Create docker-compose.yml

\- Change 'supersecurepassword' with unique password. Make sure they match for both environments

```yaml
version: '3.8'

services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:latest
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - APP_URL=http://localhost:6875
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USERNAME=bookstack_user
      - DB_PASSWORD=supersecurepassword
      - DB_DATABASE=bookstack
      - APP_KEY=base64:YOUR_GENERATED_KEY_HERE
    volumes:
      - bookstack_config:/config
    ports:
      - 6875:80
    depends_on:
      - bookstack_db
    restart: unless-stopped

  bookstack_db:
    image: mariadb:10.5
    container_name: bookstack_db
    command: --ssl=OFF
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - MYSQL_DATABASE=bookstack
      - MYSQL_USER=bookstack_user
      - MYSQL_PASSWORD=supersecurepassword
    volumes:
      - ./bookstack/db:/var/lib/mysql
    restart: unless-stopped

volumes:
  bookstack_config:

```

4. Start the Stack

```bash
docker-compose up -d
```

- This will create containers, initialize the database, run Larvel migrations and serve BookStack on port 6875

5. Check Logs 
    1. This will check if the bookstack started correctly. You should see Larvel migrations completing and no errors about SSL or DB access

```bash
docker logs bookstack
```

6. Inspect App Files 
    1. You should see Laravel files like `artisan`, `routes/`, `app/`, etc.

```bash
docker exec -it bookstack /bin/bash
ls /app/www
```

7. Create Admin User 
    1. Once completed and app is running properly, creating a local user with strong password is great way. Do this inside container

```
docker exec -it bookstack /bin/bash
cd /app/www
php artisan bookstack:create-admin
```

Optional Enhancements

- Presistent uploads/themes

```yaml
volumes:
  - ./bookstack/uploads:/config/www/uploads
  - ./bookstack/themes:/config/www/themes
```