mirror of
https://github.com/aziis98/statuspage.git
synced 2026-10-06 22:55:21 +00:00
server: env-driven config via dotenv; Dockerfile BuildKit cache mounts; db in data.volume
This commit is contained in:
+2
-1
@@ -24,7 +24,8 @@ RUN apk add --no-cache ca-certificates tzdata
|
||||
WORKDIR /app
|
||||
COPY --from=backend /out/statuspage /app/statuspage
|
||||
COPY --from=frontend /ui/dist /app/dist
|
||||
ENV CONFIG=/app/config.local.yaml
|
||||
VOLUME /app/data.volume
|
||||
EXPOSE 5000
|
||||
ENTRYPOINT ["/app/statuspage"]
|
||||
CMD ["-c", "/app/config.local.yaml", "--addr", ":5000"]
|
||||
CMD ["--addr", ":5000"]
|
||||
|
||||
@@ -7,6 +7,9 @@ services:
|
||||
volumes:
|
||||
- ./data.volume:/app/data.volume
|
||||
- ./config.local.yaml:/app/config.local.yaml:ro
|
||||
environment:
|
||||
- CONFIG=/app/config.local.yaml
|
||||
- ADDR=:5000
|
||||
cap_add:
|
||||
- NET_RAW
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -3,13 +3,12 @@ module statuspage
|
||||
go 1.26.4
|
||||
|
||||
require (
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/mattn/go-sqlite3 v1.14.49
|
||||
github.com/spf13/pflag v1.0.10
|
||||
golang.org/x/crypto v0.54.0
|
||||
golang.org/x/net v0.57.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/mattn/go-sqlite3 v1.14.49 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
)
|
||||
require golang.org/x/sys v0.47.0 // indirect
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/mattn/go-sqlite3 v1.14.49 h1:B8jBHC3xhxZgxztrgruTuLucebnULQnx4W7cF7SAE9w=
|
||||
github.com/mattn/go-sqlite3 v1.14.49/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
|
||||
+13
-3
@@ -9,9 +9,17 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func envOr(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func buildFrontend() error {
|
||||
cmd := "npm"
|
||||
if _, err := exec.LookPath("npm"); err != nil {
|
||||
@@ -43,11 +51,13 @@ func spaHandler() http.HandlerFunc {
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = godotenv.Load()
|
||||
|
||||
dev := pflag.Bool("dev", false, "run `npm run build` before serving dist/")
|
||||
devServer := pflag.Bool("dev-server", false, "frontend served by the vite dev server, do not serve dist/")
|
||||
addr := pflag.String("addr", ":5000", "listen address")
|
||||
configPath := pflag.StringP("config", "c", "config.local.yaml", "yaml config file")
|
||||
dbPath := pflag.String("db", "data.volume/history.db", "sqlite history database file")
|
||||
addr := pflag.String("addr", envOr("ADDR", ":5000"), "listen address")
|
||||
configPath := pflag.StringP("config", "c", envOr("CONFIG", "config.local.yaml"), "yaml config file")
|
||||
dbPath := pflag.String("db", envOr("DB", "data.volume/history.db"), "sqlite history database file")
|
||||
pflag.Parse()
|
||||
|
||||
if dir := filepath.Dir(*dbPath); dir != "." {
|
||||
|
||||
Reference in New Issue
Block a user