Added database config and docker image.
This commit is contained in:
parent
590910bc41
commit
259c666548
2 changed files with 29 additions and 5 deletions
|
|
@ -6,6 +6,13 @@ import (
|
||||||
"github.com/joeshaw/envdecode"
|
"github.com/joeshaw/envdecode"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TemplateDir = "views"
|
||||||
|
TemplateExt = ".gohtml"
|
||||||
|
StaticDir = "static"
|
||||||
|
StaticPrefix = "files"
|
||||||
|
)
|
||||||
|
|
||||||
type Env string
|
type Env string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -21,6 +28,7 @@ type Config struct {
|
||||||
HTTP HTTPConfig
|
HTTP HTTPConfig
|
||||||
App AppConfig
|
App AppConfig
|
||||||
Cache CacheConfig
|
Cache CacheConfig
|
||||||
|
Database DatabaseConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPConfig stores HTTP configuration
|
// 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
|
// GetConfig loads and returns application configuration
|
||||||
func GetConfig() (Config, error) {
|
func GetConfig() (Config, error) {
|
||||||
var cfg Config
|
var cfg Config
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,15 @@
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
redis:
|
cache:
|
||||||
image: "redis:alpine"
|
image: "redis:alpine"
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
|
db:
|
||||||
|
image: postgres:alpine
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=admin
|
||||||
|
- POSTGRES_PASSWORD=admin
|
||||||
|
- POSTGRES_DB=app
|
||||||
Loading…
Add table
Add a link
Reference in a new issue