Skip to content

Commit

Permalink
Merge branch 'main' into geoffw/goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
suprjinx committed Jul 13, 2023
2 parents 56f312e + d1c362f commit e2131a1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
POSTGRES_HOSTNAME=localhost
LC_COLLATE=POSIX
FML_LOG_LEVEL=DEBUG
FML_LOG_LEVEL=DEBUG
FML_DEV_MODE=true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fasttrackml

# Local database
fasttrackml.db*
encrypted.db*

# Imported integration tests
tests/integration/python/*/*.src
Expand All @@ -24,3 +25,7 @@ ignore/

# Goreleaser
dist/

# Optional workspace
go.work
*.code-workspace
12 changes: 8 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,51 @@
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"buildFlags": "-tags '${config:go.buildTags}'",
"args": [
"server",
"--database-uri",
"postgres://postgres:postgres@localhost/postgres"
]
],
},
{
"name": "Launch server (sqlite memory)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"buildFlags": "-tags '${config:go.buildTags}'",
"args": [
"server",
"--database-uri",
"sqlite://fasttrackml.db?mode=memory&cache=shared"
]
],
},
{
"name": "Launch server (sqlite file)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"buildFlags": "-tags '${config:go.buildTags}'",
"args": [
"server",
"--database-uri",
"sqlite://fasttrackml.db"
]
],
},
{
"name": "Launch server (encrypted sqlite file)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"buildFlags": "-tags '${config:go.buildTags}'",
"args": [
"server",
"--database-uri",
"sqlite://encrypted.db?_key=passphrase"
]
],
}
]
}
8 changes: 8 additions & 0 deletions pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/basicauth"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -148,6 +149,11 @@ func initServer() *fiber.App {
},
})

if viper.GetBool("dev-mode") {
log.Info("Development mode - enabling CORS")
server.Use(cors.New())
}

authUsername := viper.GetString("auth-username")
authPassword := viper.GetString("auth-password")
if authUsername != "" && authPassword != "" {
Expand Down Expand Up @@ -196,6 +202,8 @@ func init() {
ServerCmd.Flags().Bool("database-migrate", true, "Run database migrations")
ServerCmd.Flags().Bool("database-reset", false, "Reinitialize database - WARNING all data will be lost!")
ServerCmd.Flags().MarkHidden("database-reset")
ServerCmd.Flags().Bool("dev-mode", false, "Development mode - enable CORS")
ServerCmd.Flags().MarkHidden("dev-mode")
viper.BindEnv("auth-username", "MLFLOW_TRACKING_USERNAME")
viper.BindEnv("auth-password", "MLFLOW_TRACKING_PASSWORD")
}

0 comments on commit e2131a1

Please sign in to comment.