summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMikkel Thestrup <mikkel_thestrup@mithe.dk>2025-12-06 23:20:13 +0100
committerMikkel Thestrup <mikkel_thestrup@mithe.dk>2025-12-06 23:20:13 +0100
commitd243b30606673baec988c5cd0a31e450f2794ca4 (patch)
treea9bee187e9b968fe5a13e048a1c222c4d448094c /cmd
parent94646c018dfc87a7f1f9e11dc3e85d1af57899f0 (diff)
downloadweb-portfolio-d243b30606673baec988c5cd0a31e450f2794ca4.tar.gz
web-portfolio-d243b30606673baec988c5cd0a31e450f2794ca4.zip
Containerize the webserver
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/cmd/main.go b/cmd/main.go
index cd8d4fe..24ba0c9 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -1,14 +1,31 @@
package main
import (
+ "fmt"
"log"
+ "os"
"git.mithe.dk/web-portfolio/internal"
)
func main() {
- server := internal.NewSever()
- if err := server.Start("localhost:42069"); err != nil {
+ port := os.Getenv("PORT")
+ if port == "" {
+ port = "42069"
+ }
+
+ // In Docker, listen on 0.0.0.0; locally use localhost
+ host := os.Getenv("HOST")
+ if host == "" {
+ host = "0.0.0.0"
+ }
+
+ addr := fmt.Sprintf("%s:%s", host, port)
+
+ server := internal.NewServer()
+ log.Printf("Starting server on %s", addr)
+
+ if err := server.Start(addr); err != nil {
log.Fatal(err)
}
}