diff --git a/backend/Dockerfile b/backend/Dockerfile index 0aa3d57..e027070 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -11,5 +11,5 @@ RUN apk add --no-cache ca-certificates \ # Optional: timezone data for precise Prague time # RUN apk add --no-cache tzdata COPY --from=build /app/server /app/server -EXPOSE 8080 +EXPOSE 80 ENTRYPOINT ["/app/server"] diff --git a/backend/main.go b/backend/main.go index 728db29..d44f5fd 100644 --- a/backend/main.go +++ b/backend/main.go @@ -59,6 +59,14 @@ func dataPath() string { return "/app/data/club.json" } +func staticPath() string { + if p := os.Getenv("STATIC_PATH"); p != "" { + return p + } + // Default mount point for the site in the container + return "/app/site" +} + type ClubTable struct { Name string `json:"name"` ClubID string `json:"club_id"` @@ -154,12 +162,23 @@ func main() { w.Write([]byte(";")) }) + // Static file server for the frontend + fs := http.FileServer(http.Dir(staticPath())) + // Serve common asset prefixes explicitly + mux.Handle("/img/", fs) + mux.Handle("/css/", fs) + mux.Handle("/js/", fs) + mux.Handle("/blog/", fs) + mux.Handle("/zapasy/", fs) + // Fallback: serve index.html and other root-level pages + mux.Handle("/", fs) + srv := &http.Server{ - Addr: ":8080", + Addr: ":80", Handler: mux, } go func() { - log.Println("backend listening on :8080") + log.Println("server listening on :80") if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { log.Fatalf("server error: %v", err) } diff --git a/docker-compose.yml b/docker-compose.yml index ea31c73..ce0e313 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,10 @@ services: - backend: + app: build: ./backend - container_name: bizoni-backend + container_name: bizoni-app ports: - - "8080:8080" + - "80:80" volumes: - ./data:/app/data - restart: unless-stopped - web: - image: nginx:1.27-alpine - container_name: bizoni-web - depends_on: - - backend - ports: - - "8088:80" - volumes: - - ./:/usr/share/nginx/html:ro - - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + - ./:/app/site:ro restart: unless-stopped