Files
latosa-escrima/backend/main.go
cdricms fd834ea84a Setup docker for production and development
Change ./init.sh to be an executable then run it.

The default inner container ports are as followed:
- Postgres: 5432:5432
- Backend: 3001:3000
- Frontend: 3000:3000

- Frontend dev: 8000

The backend image needs to be built:

docker compose up -d --build
2025-01-14 13:44:28 +01:00

29 lines
557 B
Go

package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/joho/godotenv"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<html><body><h1>Hello, World!</h1></body></html>")
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file: %v", err)
}
port := os.Getenv("BACKEND_PORT")
http.HandleFunc("/", handler)
fmt.Printf("Serving on port %s\n", port)
err = http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
if err != nil {
fmt.Printf("Error starting server: %s\n", err)
}
}