diff --git a/Dockerfile b/Dockerfile index 899265b..9db1277 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,10 @@ RUN apk add --no-cache ca-certificates COPY --from=builder /vecna /usr/local/bin/vecna +ENV VECNA_CONFIG=/config/vecna.json + +VOLUME ["/config"] + EXPOSE 8080 ENTRYPOINT ["vecna"] diff --git a/cmd/vecna/main.go b/cmd/vecna/main.go index 77afe63..ee8bfd5 100644 --- a/cmd/vecna/main.go +++ b/cmd/vecna/main.go @@ -29,7 +29,7 @@ var rootCmd = &cobra.Command{ } func init() { - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: ./vecna.yaml)") + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", os.Getenv("VECNA_CONFIG"), "config file path (env: VECNA_CONFIG; default search: /config, $HOME, ./)") rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "log level: info | debug") rootCmd.AddCommand(convertCmd) rootCmd.AddCommand(serveCmd) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index ab50dc7..362559e 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -10,8 +10,8 @@ services: - vecna_config:/config environment: VECNA_SERVER_PORT: 8080 + # VECNA_CONFIG: /config/vecna.json # default; override to use a different path # VECNA_SERVER_API_KEYS: sk-vecna-abc123,sk-vecna-def456 - command: ["serve", "--config", "/config/vecna.json"] restart: unless-stopped depends_on: ollama: @@ -64,18 +64,18 @@ volumes: # # Run the interactive onboard wizard (writes config into the vecna_config volume): # -# docker compose run --rm -it vecna onboard --config /config/vecna.json +# docker compose run --rm -it vecna onboard # # The wizard will discover the ollama service on the Docker network at # http://ollama:11434 (select it from the list or enter the URL manually). # # Test all configured endpoints after onboarding: # -# docker compose run --rm vecna test --config /config/vecna.json +# docker compose run --rm vecna test # # Remove broken endpoints automatically: # -# docker compose run --rm vecna test --config /config/vecna.json --remove-broken +# docker compose run --rm vecna test --remove-broken # # Open the config in a shell editor (requires the alpine image): # diff --git a/pkg/config/config.go b/pkg/config/config.go index f254397..9048dc3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -79,7 +79,7 @@ func ResolveFile(cfgFile string) string { return cfgFile } home, _ := os.UserHomeDir() - dirs := []string{".", home, home + "/.config/vecna"} + dirs := []string{"/config", ".", home, home + "/.config/vecna"} for _, dir := range dirs { for _, ext := range extensions { path := dir + "/vecna." + ext @@ -117,6 +117,7 @@ func Load(cfgFile string) (*Config, error) { home, _ := os.UserHomeDir() v.SetConfigName("vecna") // No SetConfigType — viper detects format from file extension (json, yaml, toml, etc.) + v.AddConfigPath("/config") v.AddConfigPath(".") v.AddConfigPath(home) v.AddConfigPath(home + "/.config/vecna")