Skip to content

Commit e1aed6e

Browse files
committed
feat(cli): add optional core config YAML file support in Docker setup
1 parent dfce53b commit e1aed6e

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

src/client/acontext-cli/cmd/docker.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,34 @@ func promptEnvConfig() (*docker.EnvConfig, error) {
378378
return nil, fmt.Errorf("failed to get Root API Bearer Token: %w", err)
379379
}
380380

381+
// Prompt for Core Config YAML File (optional)
382+
var coreConfigYAMLFile string
383+
coreConfigPrompt := &survey.Input{
384+
Message: "5. Enter Core Config YAML File path (optional):",
385+
Default: "./config.yaml",
386+
Help: "Path to your core config.yaml file (e.g., ./config.yaml). Leave empty to use env vars only.",
387+
}
388+
if err := survey.AskOne(coreConfigPrompt, &coreConfigYAMLFile); err != nil {
389+
return nil, fmt.Errorf("failed to get Core Config YAML File: %w", err)
390+
}
391+
392+
// Convert to absolute path if provided
393+
if coreConfigYAMLFile != "" {
394+
absPath, err := filepath.Abs(coreConfigYAMLFile)
395+
if err != nil {
396+
return nil, fmt.Errorf("failed to resolve config file path: %w", err)
397+
}
398+
coreConfigYAMLFile = absPath
399+
400+
// Check if file exists (just for user feedback, not required)
401+
if _, err := os.Stat(absPath); os.IsNotExist(err) {
402+
fmt.Printf("⚠️ Note: Config file does not exist yet: %s\n", absPath)
403+
fmt.Println(" The core service will use environment variables for configuration.")
404+
} else {
405+
fmt.Printf("✅ Using config file: %s\n", absPath)
406+
}
407+
}
408+
381409
fmt.Println()
382410
fmt.Println("✅ Configuration saved!")
383411

@@ -388,5 +416,6 @@ func promptEnvConfig() (*docker.EnvConfig, error) {
388416
SDK: llmSDK,
389417
},
390418
RootAPIBearerToken: rootAPIBearerToken,
419+
CoreConfigYAMLFile: coreConfigYAMLFile,
391420
}, nil
392421
}

src/client/acontext-cli/internal/docker/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ services:
129129
S3_ENDPOINT: http://acontext-server-seaweedfs:9000
130130
ports:
131131
- "${CORE_EXPORT_PORT:-8019}:8000"
132+
volumes:
133+
- ${CORE_CONFIG_YAML_FILE:-./config.yaml}:/app/config.yaml
132134
depends_on:
133135
acontext-server-pg:
134136
condition: service_healthy

src/client/acontext-cli/internal/docker/env.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ LLM_SDK={{.LLMSDK}}
1616
1717
# API Bearer Token (for root API access)
1818
ROOT_API_BEARER_TOKEN={{.RootAPIBearerToken}}
19-
19+
{{if .CoreConfigYAMLFile}}
20+
# Core Configuration YAML File
21+
CORE_CONFIG_YAML_FILE={{.CoreConfigYAMLFile}}
22+
{{end}}
2023
# Optional: Override defaults if needed
2124
# All other settings use defaults from docker-compose.yaml
2225
# Uncomment and set values below to override docker-compose defaults:
@@ -31,15 +34,17 @@ ROOT_API_BEARER_TOKEN={{.RootAPIBearerToken}}
3134
`
3235

3336
vars := struct {
34-
LLMAPIKey string
35-
LLMBaseURL string
36-
LLMSDK string
37+
LLMAPIKey string
38+
LLMBaseURL string
39+
LLMSDK string
3740
RootAPIBearerToken string
41+
CoreConfigYAMLFile string
3842
}{
39-
LLMAPIKey: config.LLMConfig.APIKey,
40-
LLMBaseURL: config.LLMConfig.BaseURL,
41-
LLMSDK: config.LLMConfig.SDK,
43+
LLMAPIKey: config.LLMConfig.APIKey,
44+
LLMBaseURL: config.LLMConfig.BaseURL,
45+
LLMSDK: config.LLMConfig.SDK,
4246
RootAPIBearerToken: config.RootAPIBearerToken,
47+
CoreConfigYAMLFile: config.CoreConfigYAMLFile,
4348
}
4449

4550
t, err := template.New("env").Parse(tmpl)
@@ -71,6 +76,7 @@ type LLMConfig struct {
7176

7277
// EnvConfig contains all environment configuration
7378
type EnvConfig struct {
74-
LLMConfig *LLMConfig
79+
LLMConfig *LLMConfig
7580
RootAPIBearerToken string
81+
CoreConfigYAMLFile string
7682
}

0 commit comments

Comments
 (0)