diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d59680f --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/main.go b/main.go index 0cc512c..9f21f17 100644 --- a/main.go +++ b/main.go @@ -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")