Added database config and docker image.
This commit is contained in:
parent
590910bc41
commit
259c666548
@ -6,6 +6,13 @@ import (
|
||||
"github.com/joeshaw/envdecode"
|
||||
)
|
||||
|
||||
const (
|
||||
TemplateDir = "views"
|
||||
TemplateExt = ".gohtml"
|
||||
StaticDir = "static"
|
||||
StaticPrefix = "files"
|
||||
)
|
||||
|
||||
type Env string
|
||||
|
||||
const (
|
||||
@ -18,9 +25,10 @@ const (
|
||||
|
||||
// Config stores complete application configuration
|
||||
type Config struct {
|
||||
HTTP HTTPConfig
|
||||
App AppConfig
|
||||
Cache CacheConfig
|
||||
HTTP HTTPConfig
|
||||
App AppConfig
|
||||
Cache CacheConfig
|
||||
Database DatabaseConfig
|
||||
}
|
||||
|
||||
// HTTPConfig stores HTTP configuration
|
||||
@ -50,6 +58,14 @@ type CacheConfig struct {
|
||||
}
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Hostname string `env:"DB_HOSTNAME,default=localhost"`
|
||||
Port uint16 `env:"DB_PORT,default=5432"`
|
||||
User string `env:"DB_USER,default=admin"`
|
||||
Password string `env:"DB_PASSWORD,default=admin"`
|
||||
Database string `env:"DB_NAME,default=app"`
|
||||
}
|
||||
|
||||
// GetConfig loads and returns application configuration
|
||||
func GetConfig() (Config, error) {
|
||||
var cfg Config
|
||||
|
@ -1,7 +1,15 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
redis:
|
||||
cache:
|
||||
image: "redis:alpine"
|
||||
ports:
|
||||
- "6379:6379"
|
||||
- "6379:6379"
|
||||
db:
|
||||
image: postgres:alpine
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=admin
|
||||
- POSTGRES_DB=app
|
Loading…
Reference in New Issue
Block a user