# 實戰(使用docker)

### 設定容器volume

```
docker volume create bookstack_config
```

我通常能不用Dockerfile就不用，習慣直接下指令

```
docker run --restart=always -d --name=bookstack -e PUID=1000 -e PGID=1000 -e TZ=Asia/Taipei \
-v /usr/share/fonts:/usr/share/fonts -e APP_URL=https://<網址需要https>   \
-e DB_HOST=<mariadb 資料庫ip>   -e DB_PORT=3306   -e DB_USER=<帳號>   -e DB_PASS=<密碼>   -e DB_DATABASE=bookstackapp  \
-e QUEUE_CONNECTION= `#optional` -p 6875:80 -v bookstack_config:/config --restart unless-stopped   lscr.io/linuxserver/bookstack:v23.10.4-ls119

```

**<span style="color: rgb(224, 62, 45);">上面指令需要注意:</span>**  
  
1\. <span style="color: rgb(224, 62, 45);">APP\_URL </span>必須為https請準備好反向代理程式，當然也可以是ip，ip就不需要https  
  
2\. <span style="color: rgb(224, 62, 45);">DB\_HOST、DB\_PORT、DB\_USER、DB\_PASS 以及 DB\_DATABASE </span>都是mariadb database連線資訊  
  
3\. <span style="color: rgb(224, 62, 45);">6875:80</span> 將本體主機的6875拿來對應到容器的80  
  
4\. <span style="color: rgb(224, 62, 45);">/usr/share/fonts</span>使用本體的字型，這樣就不浪費空間了  
fonts目錄下，需再另外存放中文檔案，以下是免費豆腐自型

<p class="callout info">請到此下載中文字型  
[https://fonts.google.com/noto/specimen/Noto+Sans+SC](https://fonts.google.com/noto/specimen/Noto+Sans+SC)  
[https://fonts.google.com/noto/specimen/Noto+Sans+TC](https://fonts.google.com/noto/specimen/Noto+Sans+TC)</p>

  
5\. 容器 Image lscr.io/linuxserver/bookstack:<span style="color: rgb(224, 62, 45);">v23.10.4-ls119</span>

<p class="callout info">請參考 [https://github.com/BookStackApp/BookStack](https://github.com/BookStackApp/BookStack)</p>

  
6\. TZ=Asia/Taipei 系統時間

<p class="callout info">請參考[ https://worldtimeapi.org/timezone/](https://worldtimeapi.org/timezone/)</p>

<p class="callout success">安裝完畢後，請自行測試，預設帳號 <admin@admin.com> 密碼 password  
<span style="color: rgb(224, 62, 45);">登入後請修改email，修改後的email即為登入帳號；登入後請立即修改密碼</span>  
</p>

### 修改讓匯出pdf不會有亂碼  


<span style="color: rgb(224, 62, 45);">我後來發現匯出PDF功能只是將html轉為PDF檔案，並無特別排版，所以有點雞肋，但強迫症讓我必須解決中文亂碼文提</span>

```
### 進入容器
docker exec -it bookstack bash

### 刪除預設的qt5
apk del qt5-qtbase

### 修改repositories 
vi /etc/apk/repositories
### 將 3.18改成3.14
http://dl-cdn.alpinelinux.org/alpine/v3.14/main
http://dl-cdn.alpinelinux.org/alpine/v3.14/community
###

# 套用
apk update
apk upgrade
apk add wkhtmltopdf

### 測試-無法產生test.pdf 則代表失敗 
wkhtmltopdf test.html test.pdf

### 修改 .env 檔案
vi /app/www/.env
###
WKHTMLTOPDF=/usr/bin/wkhtmltopdf
ALLOW_UNTRUSTED_SERVER_FETCHING=true
###


```

<span style="color: rgb(224, 62, 45);">離開容器並且重啟，就能正常匯出中文PDF</span>

### 隱藏最近更新足跡

管理帳號登入後，請在  
<span style="color: rgb(224, 62, 45);">Settings-&gt;Customization-&gt;Custom HTML Head Content  
(設定-&gt;自訂-&gt;自訂 HTML 標題內容) </span>   
加上以下控制碼即可

```
<style>
  .tri-layout-left { visibility: hidden; }
  .tri-layout-right { visibility: hidden; }
</style>
<script>
	window.addEventListener('DOMContentLoaded', (event) => {
		const loginShowing = document.querySelector('a[href$="/login"]') == null;
		const leftPanel = document.querySelector("div.tri-layout-left");
		const rightPanel = document.querySelector("div.tri-layout-right");
		if (loginShowing) {
			leftPanel.style.visibility = 'visible';
			rightPanel.style.visibility = 'visible';
		}
	});
</script>
```

### 預設展開「章節」內容

管理帳號登入後，請在  
<span style="color: rgb(224, 62, 45);">Settings-&gt;Customization-&gt;Custom HTML Head Content  
(設定-&gt;自訂-&gt;自訂 HTML 標題內容) </span>   
加上以下控制碼即可

```
<style>
    .chapter-contents-toggle {
        display: none !important;
    }
    .inset-list {
        display: block !important;
    }
</style>
```

### 隱藏書本封面

管理帳號登入後，請在  
<span style="color: rgb(224, 62, 45);">Settings-&gt;Customization-&gt;Custom HTML Head Content  
(設定-&gt;自訂-&gt;自訂 HTML 標題內容) </span>   
加上以下控制碼即可

```
<style> 
.entity-list-item-image.bg-book { background-image: none !important; width: 5px; } .entity-list-item-image.bg-book * { display: none !important; }

.bg-book.featured-image-container-wrap .featured-image-container {
    height: 2px;
    min-height: 2px;
    background-image: none !important; 
}
.bg-book.featured-image-container-wrap *:not(.featured-image-container) {
    display: none !important;
}
</style>
```

### 讓中間文字版面變大

```
<style> 
@media screen and (min-width: 1400px) {
    .tri-layout-middle-contents {
        max-width: 1700px;
    }
}
.page-content { max-width: 1200px; }
</style> 
```

### 修改上傳檔案大小

```
docker 進入容器後，app/www/.env，設定FILE_UPLOAD_SIZE_LIMIT即可
```