summaryrefslogtreecommitdiff
path: root/issues/task_003_deployment_prep.md
blob: a05c2eb4418f99bf73c9a0315d4e0b48e58c8fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Task 003: VPS Deployment Preparation (Apache + Systemd)

Prepare the application for deployment on a VPS using Apache2 as a reverse proxy and Systemd for process management.

## Target Environment
- **OS:** Linux (VPS)
- **Web Server:** Apache2
- **Process Manager:** Systemd
- **Directory Structure:**
    - Root: `/site/{fqdn}/`
    - Binary: `/site/{fqdn}/app`
    - Data: `/site/{fqdn}/data/` (Database location)
    - Webroot: `/site/{fqdn}/public/` (Static assets)

## Plan

### 1. Configuration Updates
- Ensure the application can accept configuration via Environment Variables for:
    - `PORT` (Default: 8080)
    - `DB_PATH` (Default: `./task.db`, Target: `/site/{fqdn}/data/dashboard.db`)
    - `SESSION_KEY` (Secret)
    - `STATIC_DIR` (Optional: if we want to point to `public` explicitly)

### 2. Create Deployment Artifacts
Create a `deployment/` directory containing:

#### A. Systemd Unit File (`deployment/task-dashboard.service`)
- **Description:** Manages the Go application process.
- **Key Settings:**
    - `ExecStart=/site/{fqdn}/app`
    - `WorkingDirectory=/site/{fqdn}/`
    - `User=www-data` (or specific user)
    - `Restart=always`
    - `EnvironmentFile=/site/{fqdn}/.env` (or inline env vars)

#### B. Apache VHost Configuration (`deployment/apache.conf`)
- **Description:** Reverse proxy configuration.
- **Key Settings:**
    - Based on provided template.
    - `DocumentRoot /site/{fqdn}/public`
    - `ProxyPass / http://localhost:8080/`
    - `ProxyPassReverse / http://localhost:8080/`
    - Serve static assets directly via Apache for performance (optional but recommended).

### 3. Documentation
- Create `docs/deployment.md` with instructions:
    1.  **Build:** `go build -o app cmd/dashboard/main.go`
    2.  **Setup:**
        - `mkdir -p /site/{fqdn}/{data,public}`
        - Copy `app` to `/site/{fqdn}/`
        - Copy `web/static` content to `/site/{fqdn}/public/`
        - Copy `web/templates` to `/site/{fqdn}/templates` (or ensure app can find them)
    3.  **Service:** Install and enable systemd service.
    4.  **Apache:** Enable site and modules (`proxy`, `proxy_http`).

## Considerations
- **Static Files:** We should decide if Apache serves `/static` directly from `/site/{fqdn}/public` or if the Go app handles it. Serving via Apache is preferred for performance.
- **Templates:** The Go app needs access to HTML templates. We need to ensure the `WorkingDirectory` allows relative path resolution to `web/templates` or configure an absolute path.