This commit is contained in:
lehel 2025-09-30 21:59:35 +02:00
parent 921d51b97c
commit b63ae2ba43
No known key found for this signature in database
GPG Key ID: 9C4F9D6111EE5CFA
2 changed files with 53 additions and 0 deletions

49
Dockerfile Normal file
View File

@ -0,0 +1,49 @@
# ---- Builder Stage ----
FROM golang:1.25.1-bookworm AS builder
# Build Args
ARG BUILD_COMMAND="go build -o app ."
ARG BINARY_NAME="app"
ARG CGO_ENABLED="0"
# Env setup
ENV CGO_ENABLED=${CGO_ENABLED}
# Setup workdir
WORKDIR /build
# Copy go.mod and go.sum first to leverage caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build with Go build cache (requires BuildKit)
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
${BUILD_COMMAND}
# ---- Runner Stage ----
FROM debian:bookworm-slim AS runner
# Install minimal runtime dependencies (e.g. for TLS, CA certs)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Build Args
ARG BINARY_NAME="app"
# Setup workdir
WORKDIR /user
# Copy binary and config files
COPY --from=builder /build/${BINARY_NAME} ./app
COPY config.yaml .
COPY db.yaml .
COPY ui.html .
# Run binary directly
ENTRYPOINT ["./app"]

View File

@ -30,6 +30,10 @@ func main() {
c.Status(200)
uiTemplate.Execute(c.Writer, nil)
})
r.GET("/health", func(c *gin.Context) {
c.Status(200)
c.JSON(200, gin.H{"status": "ok"})
})
r.POST("/chat", chatService.HandleChat)
r.Run(":8080")