This commit is contained in:
Tomas Dvorak
2025-09-08 17:13:01 +02:00
parent 0e70f4e36b
commit 91947a53b5
3 changed files with 26 additions and 17 deletions
+1 -1
View File
@@ -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"]
+21 -2
View File
@@ -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)
}
+4 -14
View File
@@ -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