diff --git a/config/config.go b/config/config.go index a653e31..a2a1371 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index a008282..ad78bd2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,15 @@ version: "3" services: - redis: + cache: image: "redis:alpine" ports: - - "6379:6379" \ No newline at end of file + - "6379:6379" + db: + image: postgres:alpine + ports: + - "5432:5432" + environment: + - POSTGRES_USER=admin + - POSTGRES_PASSWORD=admin + - POSTGRES_DB=app \ No newline at end of file