cdf21682d6
AES-256-GCM encryption for credential storage, YAML seed config parser with validation, and transactional import into SQLite. Credentials (registry tokens, NPM password) encrypted before storage.
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/alexei/docker-watcher/internal/config"
|
|
"github.com/alexei/docker-watcher/internal/store"
|
|
)
|
|
|
|
func main() {
|
|
dataDir := envOrDefault("DATA_DIR", "./data")
|
|
|
|
if err := os.MkdirAll(dataDir, 0o755); err != nil {
|
|
log.Fatalf("create data directory: %v", err)
|
|
}
|
|
|
|
dbPath := filepath.Join(dataDir, "docker-watcher.db")
|
|
db, err := store.New(dbPath)
|
|
if err != nil {
|
|
log.Fatalf("open store: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
// Import seed config on first launch (idempotent — skipped if DB has data).
|
|
seedPath := envOrDefault("SEED_FILE", "./docker-watcher.yaml")
|
|
if err := config.ImportSeed(db, seedPath); err != nil {
|
|
log.Fatalf("seed import: %v", err)
|
|
}
|
|
|
|
fmt.Printf("Docker Watcher started. Database: %s\n", dbPath)
|
|
|
|
// Future phases will wire up the HTTP server, deployer, poller, etc.
|
|
}
|
|
|
|
// envOrDefault reads an environment variable or returns the fallback value.
|
|
func envOrDefault(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|