79 lines
1.3 KiB
Markdown
79 lines
1.3 KiB
Markdown
# Application Binary Pattern Notes
|
|
|
|
This file keeps examples and rollout snippets. The normative rules live in `contract.md`.
|
|
|
|
## Host Layout
|
|
|
|
Default application root:
|
|
|
|
```text
|
|
/appdata/<appname>/
|
|
```
|
|
|
|
Example:
|
|
|
|
```bash
|
|
scp bin/myservice user@host:/appdata/myservice/myservice
|
|
scp docker-compose.yml user@host:/appdata/myservice/docker-compose.yml
|
|
ssh user@host "mkdir -p /appdata/myservice"
|
|
ssh user@host "cd /appdata/myservice && docker compose up -d"
|
|
```
|
|
|
|
## Embedded Resources
|
|
|
|
Typical embedded assets:
|
|
|
|
- HTML templates
|
|
- static JS/CSS/icons
|
|
- `config.template.yaml`
|
|
- DB migrations
|
|
|
|
## Config Template Example
|
|
|
|
```yaml
|
|
# <appname> configuration
|
|
# Generated on first run. Edit as needed.
|
|
|
|
server:
|
|
port: 8080
|
|
|
|
database:
|
|
host: localhost
|
|
port: 5432
|
|
user: ""
|
|
password: ""
|
|
dbname: ""
|
|
```
|
|
|
|
## First-Run Behavior
|
|
|
|
```text
|
|
Start
|
|
-> config missing
|
|
-> create directory
|
|
-> write template
|
|
-> print config path
|
|
-> exit 0
|
|
```
|
|
|
|
Expected message:
|
|
|
|
```text
|
|
Config created: ~/.config/<appname>/config.yaml
|
|
Edit the file and restart the application.
|
|
```
|
|
|
|
## Build Examples
|
|
|
|
Without CGO:
|
|
|
|
```bash
|
|
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/<appname> ./cmd/<appname>
|
|
```
|
|
|
|
With CGO where required:
|
|
|
|
```bash
|
|
CGO_ENABLED=1 go build -ldflags="-s -w" -o bin/<appname> ./cmd/<appname>
|
|
```
|