Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.24.2-bookworm AS builder

WORKDIR /app

COPY . /app

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux go build -o main cmd/main/hello.go

FROM debian:bookworm-slim

WORKDIR /app

COPY --from=builder /app/main .

CMD ["./main"]
8 changes: 5 additions & 3 deletions cmd/main/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ func main() {
go checkBalanceLoop()
go checkTransLoop()

// http.ListenAndServeTLS(config.ListenAddr, "cert.pem", "key.pem", nil)
http.ListenAndServe(cfg.ListenAddr, xfbbroker.CreateApiServer(cfg))
fmt.Println("Hello, World!")
if cfg.ListenTLS {
http.ListenAndServeTLS(cfg.ListenAddr, cfg.TLSCertFile, cfg.TLSKeyFile, xfbbroker.CreateApiServer(cfg))
} else {
http.ListenAndServe(cfg.ListenAddr, xfbbroker.CreateApiServer(cfg))
}
}
3 changes: 3 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type Config struct {
CheckTransInterval int
CheckBalanceInterval int
ListenAddr string
ListenTLS bool
TLSCertFile string
TLSKeyFile string
AuthLocalUrl string
AuthCallback string
}
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./config.json:/app/config.json:ro
ports:
- "8000:8000"