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)
|
||||
|
||||
```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`
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
Reference in a new issue