feat: build entire backend into single executable (including migrations etc)

This commit is contained in:
Sam 2023-03-15 10:04:48 +01:00
parent f94bc67f3d
commit ded9d06e4a
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
12 changed files with 137 additions and 32 deletions

View file

@ -1,4 +1,4 @@
package main
package backend
import (
"context"
@ -12,14 +12,22 @@ import (
"github.com/go-chi/render"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli/v2"
)
func main() {
var Command = &cli.Command{
Name: "web",
Usage: "Run the API server",
Action: run,
}
func run(c *cli.Context) error {
port := ":" + os.Getenv("PORT")
s, err := server.New()
if err != nil {
log.Fatalf("Error creating server: %v", err)
return nil
}
// set render.Decode to a custom one that checks content length
@ -44,10 +52,12 @@ func main() {
case <-ctx.Done():
log.Info("Interrupt signal received, shutting down...")
s.DB.Close()
return
return nil
case err := <-e:
log.Fatalf("Error running server: %v", err)
}
return nil
}
const MaxContentLength = 2 * 1024 * 1024

View file

@ -1,4 +1,4 @@
package main
package backend
import (
"codeberg.org/u1f320/pronouns.cc/backend/routes/auth"

View file

@ -16,7 +16,10 @@ import (
)
// Revision is the git commit, filled at build time
var Revision = "[unknown]"
var (
Revision = "[unknown]"
Tag = "[unknown]"
)
// Repository is the URL of the git repository
const Repository = "https://codeberg.org/u1f320/pronouns.cc"