chore: add multistage build to optimize the image size

This commit is contained in:
Lakhan Samani
2021-07-21 17:53:22 +05:30
parent a528fe2f26
commit 40ad01e6b7
4 changed files with 24 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package constants
import (
"flag"
"log"
"os"
"strings"
@@ -36,6 +37,19 @@ var (
VERIFY_EMAIL_URI = ""
)
func ParseArgs() {
dbURL := flag.String("db_url", "", "Database connection string")
dbType := flag.String("db_type", "", "Database type, possible values are postgres,mysql,sqlit")
flag.Parse()
if *dbURL != "" {
DB_URL = *dbURL
}
if *dbType != "" {
DB_TYPE = *dbType
}
}
func init() {
err := godotenv.Load()
if err != nil {
@@ -78,6 +92,8 @@ func init() {
IS_PROD = false
}
ParseArgs()
if DB_TYPE == "" {
DB_TYPE = enum.Postgres.String()
}

View File

@@ -34,6 +34,7 @@ var Mgr Manager
func init() {
var db *gorm.DB
var err error
log.Println("=> from db:", constants.DB_TYPE, constants.DB_URL)
ormConfig := &gorm.Config{
NamingStrategy: schema.NamingStrategy{
TablePrefix: "yauth_",