ffs
This commit is contained in:
parent
e7bd20eae9
commit
434adf1f66
3 changed files with 17 additions and 2 deletions
|
|
@ -26,8 +26,10 @@ RUN tar -xzf /tmp/onnx.tgz -C /tmp
|
||||||
RUN mkdir -p /usr/local/lib && cp /tmp/onnxruntime-linux-x64-1.27.0/lib/libonnxruntime.so* /usr/local/lib/
|
RUN mkdir -p /usr/local/lib && cp /tmp/onnxruntime-linux-x64-1.27.0/lib/libonnxruntime.so* /usr/local/lib/
|
||||||
RUN rm -rf /tmp/onnxruntime-linux-x64-1.27.0 /tmp/onnx.tgz
|
RUN rm -rf /tmp/onnxruntime-linux-x64-1.27.0 /tmp/onnx.tgz
|
||||||
|
|
||||||
# Build Go binary with CGO enabled
|
# Build Go binary with CGO enabled, baking in the git commit (provided by Coolify)
|
||||||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o /app/vector-server main.go 2>&1
|
ARG SOURCE_COMMIT=dev
|
||||||
|
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
|
||||||
|
go build -ldflags "-X main.version=${SOURCE_COMMIT}" -o /app/vector-server main.go 2>&1
|
||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -8,7 +8,9 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/emirpasic/gods v1.18.1 // indirect
|
||||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||||
|
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/schollz/progressbar/v2 v2.15.0 // indirect
|
github.com/schollz/progressbar/v2 v2.15.0 // indirect
|
||||||
github.com/sugarme/regexpset v0.0.0-20200920021344-4d4ec8eaf93c // indirect
|
github.com/sugarme/regexpset v0.0.0-20200920021344-4d4ec8eaf93c // indirect
|
||||||
|
|
|
||||||
11
main.go
11
main.go
|
|
@ -20,6 +20,7 @@ var (
|
||||||
session *onnxruntime_go.DynamicAdvancedSession
|
session *onnxruntime_go.DynamicAdvancedSession
|
||||||
maxLen = int64(128)
|
maxLen = int64(128)
|
||||||
embeddingSize = int64(384)
|
embeddingSize = int64(384)
|
||||||
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -218,6 +219,15 @@ func healthHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
|
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func versionHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
v := os.Getenv("SOURCE_COMMIT")
|
||||||
|
if v == "" {
|
||||||
|
v = version
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(map[string]string{"version": v})
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
|
|
@ -226,6 +236,7 @@ func main() {
|
||||||
|
|
||||||
http.HandleFunc("/vector", vectorHandler)
|
http.HandleFunc("/vector", vectorHandler)
|
||||||
http.HandleFunc("/ok", healthHandler)
|
http.HandleFunc("/ok", healthHandler)
|
||||||
|
http.HandleFunc("/version", versionHandler)
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
log.Printf("Starting server on port %s...\n", port)
|
log.Printf("Starting server on port %s...\n", port)
|
||||||
log.Fatal(http.ListenAndServe(":"+port, loggingMiddleware(http.DefaultServeMux)))
|
log.Fatal(http.ListenAndServe(":"+port, loggingMiddleware(http.DefaultServeMux)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue