更新 Service:Coder
+62
-56
@@ -1,56 +1,62 @@
|
|||||||
# 簡介
|
# 簡介
|
||||||
|
|
||||||
Coder 是自架的雲端開發環境平台,可在伺服器上建立並管理遠端開發工作區。本文記錄在 Ubuntu 上安裝 Coder,並使用 PostgreSQL 作為資料庫的步驟。
|
Coder 是自架的雲端開發環境平台,可在伺服器上建立並管理遠端開發工作區。本文記錄在 Ubuntu 上安裝 Coder,並使用 PostgreSQL 作為資料庫的步驟。
|
||||||
|
|
||||||
# 安裝 Coder
|
# 安裝 Coder
|
||||||
|
|
||||||
透過官方安裝腳本安裝。
|
透過官方安裝腳本安裝。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -L https://coder.com/install.sh | sh
|
curl -L https://coder.com/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
# 修改 Coder 綁定的位址
|
# 修改 Coder 綁定的位址
|
||||||
|
|
||||||
預設僅綁定本機,改為 `0.0.0.0:3000` 以開放外部連線。
|
預設僅綁定本機,改為 `0.0.0.0:3000` 以開放外部連線。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo 'export CODER_HTTP_ADDRESS=0.0.0.0:3000' >> ~/.bashrc && source ~/.bashrc
|
echo 'export CODER_HTTP_ADDRESS=0.0.0.0:3000' >> ~/.bashrc && source ~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
# 啟動服務
|
# 設定 Coder 服務檔
|
||||||
|
|
||||||
設為開機自動啟動並立即啟動服務。
|
```bash
|
||||||
|
systemctl edit coder
|
||||||
```bash
|
```
|
||||||
systemctl enable --now coder
|
|
||||||
```
|
# 啟動服務
|
||||||
|
|
||||||
# 設定資料庫
|
設為開機自動啟動並立即啟動服務。
|
||||||
|
|
||||||
以 postgres 系統帳號進入 PostgreSQL 互動介面。
|
```bash
|
||||||
|
systemctl enable --now coder
|
||||||
```bash
|
```
|
||||||
sudo -u postgres psql
|
|
||||||
```
|
# 設定資料庫
|
||||||
|
|
||||||
新建專屬使用者與資料庫。
|
以 postgres 系統帳號進入 PostgreSQL 互動介面。
|
||||||
|
|
||||||
```sql
|
```bash
|
||||||
CREATE USER coder WITH PASSWORD 'coder';
|
sudo -u postgres psql
|
||||||
|
```
|
||||||
CREATE DATABASE coder;
|
|
||||||
```
|
新建專屬使用者與資料庫。
|
||||||
|
|
||||||
設定資料庫權限(Postgres 15 以後,schema 權限需另外授予,否則應用程式無法建立資料表)。
|
```sql
|
||||||
|
CREATE USER coder WITH PASSWORD 'coder';
|
||||||
```sql
|
|
||||||
-- 1. Give ownership of the database to the app user
|
CREATE DATABASE coder;
|
||||||
ALTER DATABASE coder OWNER TO coder;
|
```
|
||||||
|
|
||||||
-- 2. Give ownership of the public schema to the app user
|
設定資料庫權限(Postgres 15 以後,schema 權限需另外授予,否則應用程式無法建立資料表)。
|
||||||
ALTER SCHEMA public OWNER TO coder;
|
|
||||||
|
```sql
|
||||||
-- 3. Ensure the user has create permissions (Crucial for Postgres 15+)
|
-- 1. Give ownership of the database to the app user
|
||||||
GRANT USAGE, CREATE ON SCHEMA public TO coder;
|
ALTER DATABASE coder OWNER TO coder;
|
||||||
```
|
|
||||||
|
-- 2. Give ownership of the public schema to the app user
|
||||||
|
ALTER SCHEMA public OWNER TO coder;
|
||||||
|
|
||||||
|
-- 3. Ensure the user has create permissions (Crucial for Postgres 15+)
|
||||||
|
GRANT USAGE, CREATE ON SCHEMA public TO coder;
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user