Merge pull request 'Permettre de configurer api
et web
par .env
' (#46) from feature/config-depuis-env into main
Reviewed-on: #46
This commit is contained in:
commit
585c626e1c
3 changed files with 19 additions and 0 deletions
|
@ -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)
|
(Remplacer `bottin` par quelque chose de plus sécuritaire)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
BOTTIN_API_KEY=bottin
|
||||||
BOTTIN_POSTGRES_DATABASE=bottin
|
BOTTIN_POSTGRES_DATABASE=bottin
|
||||||
BOTTIN_POSTGRES_PASSWORD=bottin
|
BOTTIN_POSTGRES_PASSWORD=bottin
|
||||||
BOTTIN_POSTGRES_USER=bottin
|
BOTTIN_POSTGRES_USER=bottin
|
||||||
|
BOTTIN_WEB_PASSWORD=bottin
|
||||||
|
BOTTIN_WEB_USER=bottin
|
||||||
```
|
```
|
||||||
|
|
||||||
Déployer avec docker-compose
|
Déployer avec docker-compose
|
||||||
|
|
||||||
`$ docker-compose up -d`
|
`$ 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
|
Pour modifier la configuration du serveur API
|
||||||
|
|
||||||
`$ docker-compose exec -it api vi /etc/bottin/api.yaml`
|
`$ docker-compose exec -it api vi /etc/bottin/api.yaml`
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -47,6 +48,8 @@ func initConfig() {
|
||||||
viper.SetConfigName(".bottin")
|
viper.SetConfigName(".bottin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viper.SetEnvPrefix("BOTTIN")
|
||||||
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
viper.AutomaticEnv() // read in environment variables that match
|
||||||
|
|
||||||
// If a config file is found, read it in.
|
// If a config file is found, read it in.
|
||||||
|
|
|
@ -15,6 +15,11 @@ services:
|
||||||
- db
|
- db
|
||||||
build: .
|
build: .
|
||||||
image: 'git.agecem.com/agecem/bottin:latest'
|
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:
|
ports:
|
||||||
- '1312:1312'
|
- '1312:1312'
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -27,6 +32,10 @@ services:
|
||||||
- api
|
- api
|
||||||
build: .
|
build: .
|
||||||
image: 'git.agecem.com/agecem/bottin:latest'
|
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:
|
ports:
|
||||||
- '2312:2312'
|
- '2312:2312'
|
||||||
volumes:
|
volumes:
|
||||||
|
|
Loading…
Reference in a new issue