diff --git a/README.md b/README.md index 74d3152..acda47f 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,22 @@ Remplir .env avec les infos qui seront utilisées pour déployer le container (Remplacer `bottin` par quelque chose de plus sécuritaire) ```sh +BOTTIN_API_KEY=bottin BOTTIN_POSTGRES_DATABASE=bottin BOTTIN_POSTGRES_PASSWORD=bottin BOTTIN_POSTGRES_USER=bottin +BOTTIN_WEB_PASSWORD=bottin +BOTTIN_WEB_USER=bottin ``` Déployer avec docker-compose `$ docker-compose up -d` +### Optionnel: configuration par fichiers YAML + +*seulement nécessaire si les fichiers `.env` et `docker-compose.yaml` ne contiennent pas toute l'information nécessaire* + Pour modifier la configuration du serveur API `$ docker-compose exec -it api vi /etc/bottin/api.yaml` diff --git a/cmd/root.go b/cmd/root.go index 94350ca..0b7562e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "os" + "strings" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -47,6 +48,8 @@ func initConfig() { viper.SetConfigName(".bottin") } + viper.SetEnvPrefix("BOTTIN") + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. diff --git a/docker-compose.yaml b/docker-compose.yaml index cad1268..1f739d8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,6 +15,11 @@ services: - db build: . image: 'git.agecem.com/agecem/bottin:latest' + environment: + BOTTIN_DB_DATABASE: "${BOTTIN_POSTGRES_DATABASE}" + BOTTIN_DB_PASSWORD: "${BOTTIN_POSTGRES_PASSWORD}" + BOTTIN_DB_USER: "${BOTTIN_POSTGRES_USER}" + BOTTIN_API_KEY: "${BOTTIN_API_KEY}" ports: - '1312:1312' volumes: @@ -27,6 +32,10 @@ services: - api build: . image: 'git.agecem.com/agecem/bottin:latest' + environment: + BOTTIN_WEB_API_KEY: "${BOTTIN_API_KEY}" + BOTTIN_WEB_PASSWORD: "${BOTTIN_WEB_PASSWORD}" + BOTTIN_WEB_USER: "${BOTTIN_WEB_USER}" ports: - '2312:2312' volumes: