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
This commit is contained in:
28
backend/main.go
Normal file
28
backend/main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user