Compare commits
1 Commits
cf825a7260
...
feat/upaas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35af9c99d5 |
@@ -6,3 +6,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
bin/
|
bin/
|
||||||
data/
|
data/
|
||||||
|
deploy/
|
||||||
|
|||||||
@@ -75,4 +75,7 @@ WORKDIR /var/lib/pixa
|
|||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||||
|
CMD wget -q --spider http://localhost:8080/.well-known/healthcheck.json
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/pixad", "--config", "/etc/pixa/config.yml"]
|
ENTRYPOINT ["/usr/local/bin/pixad", "--config", "/etc/pixa/config.yml"]
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -125,6 +125,17 @@ See `config.example.yml` for all options with defaults.
|
|||||||
- **Metrics**: Prometheus
|
- **Metrics**: Prometheus
|
||||||
- **Logging**: stdlib slog
|
- **Logging**: stdlib slog
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Pixa is deployed via
|
||||||
|
[µPaaS](https://git.eeqj.de/sneak/upaas) on `fsn1app1`
|
||||||
|
(paas.datavi.be). Pushes to `main` trigger automatic builds and
|
||||||
|
deployments. The Dockerfile includes a `HEALTHCHECK` that probes
|
||||||
|
`/.well-known/healthcheck.json`.
|
||||||
|
|
||||||
|
See [deploy/README.md](deploy/README.md) for the full µPaaS app
|
||||||
|
configuration, volume mounts, and production setup instructions.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
See [TODO.md](TODO.md) for the full prioritized task list.
|
See [TODO.md](TODO.md) for the full prioritized task list.
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ import (
|
|||||||
"sneak.berlin/go/pixa/internal/server"
|
"sneak.berlin/go/pixa/internal/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version string //nolint:gochecknoglobals // set by ldflags
|
var (
|
||||||
|
Appname = "pixad" //nolint:gochecknoglobals // set by ldflags
|
||||||
|
Version string //nolint:gochecknoglobals // set by ldflags
|
||||||
|
)
|
||||||
|
|
||||||
var configPath string //nolint:gochecknoglobals // cobra flag
|
var configPath string //nolint:gochecknoglobals // cobra flag
|
||||||
|
|
||||||
@@ -37,6 +40,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(_ *cobra.Command, _ []string) {
|
func run(_ *cobra.Command, _ []string) {
|
||||||
|
globals.Appname = Appname
|
||||||
globals.Version = Version
|
globals.Version = Version
|
||||||
|
|
||||||
// Set config path in environment if specified via flag
|
// Set config path in environment if specified via flag
|
||||||
|
|||||||
78
deploy/README.md
Normal file
78
deploy/README.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Pixa Deployment via µPaaS
|
||||||
|
|
||||||
|
Pixa is deployed on `fsn1app1` via
|
||||||
|
[µPaaS](https://git.eeqj.de/sneak/upaas) (paas.datavi.be).
|
||||||
|
|
||||||
|
## µPaaS App Configuration
|
||||||
|
|
||||||
|
Create the app in the µPaaS web UI with these settings:
|
||||||
|
|
||||||
|
| Setting | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| **App name** | `pixa` |
|
||||||
|
| **Repo URL** | `git@git.eeqj.de:sneak/pixa.git` |
|
||||||
|
| **Branch** | `main` |
|
||||||
|
| **Dockerfile path** | `Dockerfile` |
|
||||||
|
|
||||||
|
### Environment Variables
|
||||||
|
|
||||||
|
| Variable | Description | Required |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `PORT` | HTTP listen port (default: 8080) | No |
|
||||||
|
|
||||||
|
Configuration is provided via the config file baked into the Docker
|
||||||
|
image at `/etc/pixa/config.yml`. To override it, mount a custom
|
||||||
|
config file as a volume (see below).
|
||||||
|
|
||||||
|
### Volumes
|
||||||
|
|
||||||
|
| Host Path | Container Path | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `/srv/pixa/data` | `/var/lib/pixa` | SQLite database and image cache |
|
||||||
|
| `/srv/pixa/config.yml` | `/etc/pixa/config.yml` | Production config (signing key, whitelist, etc.) |
|
||||||
|
|
||||||
|
### Ports
|
||||||
|
|
||||||
|
| Host Port | Container Port | Protocol |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| (assigned) | 8080 | TCP |
|
||||||
|
|
||||||
|
### Docker Network
|
||||||
|
|
||||||
|
Attach to the shared reverse-proxy network if using Caddy/Traefik
|
||||||
|
for TLS termination.
|
||||||
|
|
||||||
|
## Production Configuration
|
||||||
|
|
||||||
|
Copy `config.example.yml` from the repo root and customize for
|
||||||
|
production:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
port: 8080
|
||||||
|
debug: false
|
||||||
|
maintenance_mode: false
|
||||||
|
state_dir: /var/lib/pixa
|
||||||
|
signing_key: "<generate with: openssl rand -base64 32>"
|
||||||
|
whitelist_hosts:
|
||||||
|
- s3.sneak.cloud
|
||||||
|
- static.sneak.cloud
|
||||||
|
- sneak.berlin
|
||||||
|
allow_http: false
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important:** Generate a unique `signing_key` for production. Never
|
||||||
|
use the default placeholder value.
|
||||||
|
|
||||||
|
## Health Check
|
||||||
|
|
||||||
|
The Dockerfile includes a `HEALTHCHECK` instruction that probes
|
||||||
|
`/.well-known/healthcheck.json` every 30 seconds. µPaaS verifies
|
||||||
|
container health 60 seconds after deployment.
|
||||||
|
|
||||||
|
## Deployment Flow
|
||||||
|
|
||||||
|
1. Push to `main` triggers the Gitea webhook
|
||||||
|
2. µPaaS clones the repo and runs `docker build .`
|
||||||
|
3. The Dockerfile runs `make check` (format, lint, test) during build
|
||||||
|
4. On success, µPaaS stops the old container and starts the new one
|
||||||
|
5. After 60 seconds, µPaaS checks container health
|
||||||
@@ -5,10 +5,11 @@ import (
|
|||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const appname = "pixad"
|
// Build-time variables populated from main() via ldflags.
|
||||||
|
var (
|
||||||
// Version is populated from main() via ldflags.
|
Appname string //nolint:gochecknoglobals // set from main
|
||||||
var Version string //nolint:gochecknoglobals // set from main
|
Version string //nolint:gochecknoglobals // set from main
|
||||||
|
)
|
||||||
|
|
||||||
// Globals holds application-wide constants.
|
// Globals holds application-wide constants.
|
||||||
type Globals struct {
|
type Globals struct {
|
||||||
@@ -19,7 +20,7 @@ type Globals struct {
|
|||||||
// New creates a new Globals instance from build-time variables.
|
// New creates a new Globals instance from build-time variables.
|
||||||
func New(_ fx.Lifecycle) (*Globals, error) {
|
func New(_ fx.Lifecycle) (*Globals, error) {
|
||||||
return &Globals{
|
return &Globals{
|
||||||
Appname: appname,
|
Appname: Appname,
|
||||||
Version: Version,
|
Version: Version,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user