diff --git a/build.yml b/build.yml
index efb5f500acbd0739e86b6f21755bfb68147d821b..4917a59cebb6d07848cca85956588dcd98d7b6d9 100644
--- a/build.yml
+++ b/build.yml
@@ -13,13 +13,14 @@
environment:
deploy: builds@gabrielgio.me
target: artifacts.gabrielgio.me/midr/
+ version: v0.1.1
tasks:
- archive: |
cd midr
git archive \
- -o midr-v0.1.0.tar.gz \
- --prefix=midr-v0.1.0/ HEAD
+ -o midr-$version.tar.gz \
+ --prefix=midr-$version/ HEAD
- deploy: |
cd midr
diff --git a/db/db.go b/db/db.go
index 948f154b5d8ccc83966dd02adfe3ea8b0cba6426..4728aa71622267539f0dea931707c969a3796338 100644
--- a/db/db.go
+++ b/db/db.go
@@ -1,6 +1,8 @@
package db
import (
+ "path"
+
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -10,8 +12,10 @@ DB *gorm.DB
err error
)
-func ConnectDb() {
- DB, err = gorm.Open(sqlite.Open("main.db"), &gorm.Config{})
+func ConnectDb(folder string) {
+ dbPath := path.Join(folder, "main.db")
+
+ DB, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
if err != nil {
panic("failed to connect to the database.")
diff --git a/main.go b/main.go
index c763c5adbc4fc791c9bb06c86accc53feb37b4d9..247d75166f18df357e0f099c73d4d6907e82879c 100644
--- a/main.go
+++ b/main.go
@@ -2,19 +2,30 @@ package main
import (
"embed"
+ "flag"
"fmt"
"git.sr.ht/~gabrielgio/midr/db"
"git.sr.ht/~gabrielgio/midr/routes"
+ "github.com/gin-gonic/gin"
)
var Version = "development"
+var dataDir = flag.String("d", ".", "Folder where midr will store the data")
+var production = flag.Bool("p", false, "Set production")
//go:embed assets/* templates/*
var f embed.FS
func main() {
+ flag.Parse()
fmt.Println("Version:\t", Version)
- db.ConnectDb()
+ fmt.Println("Datadir:\t", *dataDir)
+
+ if *production {
+ gin.SetMode(gin.ReleaseMode)
+ }
+
+ db.ConnectDb(*dataDir)
routes.HandleRequests(f)
}