mirror of
https://github.com/Warky-Devs/vecna.git
synced 2026-05-05 01:26:58 +00:00
feat(docker): add configurable path for vecna.json
* set default config path to /config * update docker-compose example for config usage * modify config resolution to include /config directory
This commit is contained in:
@@ -16,6 +16,10 @@ RUN apk add --no-cache ca-certificates
|
|||||||
|
|
||||||
COPY --from=builder /vecna /usr/local/bin/vecna
|
COPY --from=builder /vecna /usr/local/bin/vecna
|
||||||
|
|
||||||
|
ENV VECNA_CONFIG=/config/vecna.json
|
||||||
|
|
||||||
|
VOLUME ["/config"]
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT ["vecna"]
|
ENTRYPOINT ["vecna"]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var rootCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
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.PersistentFlags().StringVar(&logLevel, "log-level", "info", "log level: info | debug")
|
||||||
rootCmd.AddCommand(convertCmd)
|
rootCmd.AddCommand(convertCmd)
|
||||||
rootCmd.AddCommand(serveCmd)
|
rootCmd.AddCommand(serveCmd)
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ services:
|
|||||||
- vecna_config:/config
|
- vecna_config:/config
|
||||||
environment:
|
environment:
|
||||||
VECNA_SERVER_PORT: 8080
|
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
|
# VECNA_SERVER_API_KEYS: sk-vecna-abc123,sk-vecna-def456
|
||||||
command: ["serve", "--config", "/config/vecna.json"]
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
ollama:
|
ollama:
|
||||||
@@ -64,18 +64,18 @@ volumes:
|
|||||||
#
|
#
|
||||||
# Run the interactive onboard wizard (writes config into the vecna_config volume):
|
# 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
|
# 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).
|
# http://ollama:11434 (select it from the list or enter the URL manually).
|
||||||
#
|
#
|
||||||
# Test all configured endpoints after onboarding:
|
# 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:
|
# 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):
|
# Open the config in a shell editor (requires the alpine image):
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func ResolveFile(cfgFile string) string {
|
|||||||
return cfgFile
|
return cfgFile
|
||||||
}
|
}
|
||||||
home, _ := os.UserHomeDir()
|
home, _ := os.UserHomeDir()
|
||||||
dirs := []string{".", home, home + "/.config/vecna"}
|
dirs := []string{"/config", ".", home, home + "/.config/vecna"}
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
for _, ext := range extensions {
|
for _, ext := range extensions {
|
||||||
path := dir + "/vecna." + ext
|
path := dir + "/vecna." + ext
|
||||||
@@ -117,6 +117,7 @@ func Load(cfgFile string) (*Config, error) {
|
|||||||
home, _ := os.UserHomeDir()
|
home, _ := os.UserHomeDir()
|
||||||
v.SetConfigName("vecna")
|
v.SetConfigName("vecna")
|
||||||
// No SetConfigType — viper detects format from file extension (json, yaml, toml, etc.)
|
// No SetConfigType — viper detects format from file extension (json, yaml, toml, etc.)
|
||||||
|
v.AddConfigPath("/config")
|
||||||
v.AddConfigPath(".")
|
v.AddConfigPath(".")
|
||||||
v.AddConfigPath(home)
|
v.AddConfigPath(home)
|
||||||
v.AddConfigPath(home + "/.config/vecna")
|
v.AddConfigPath(home + "/.config/vecna")
|
||||||
|
|||||||
Reference in New Issue
Block a user