Spaces:
Running
Running
File size: 1,928 Bytes
b110593 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// _ _
// __ _____ __ ___ ___ __ _| |_ ___
// \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
// \ V V / __/ (_| |\ V /| | (_| | || __/
// \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
//
// Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
//
// CONTACT: [email protected]
//
package docker
import (
"context"
"fmt"
"time"
"github.com/docker/go-connections/nat"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
const Multi2VecCLIP = "multi2vec-clip"
func startM2VClip(ctx context.Context, networkName, clipImage string) (*DockerContainer, error) {
image := "semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1"
if len(clipImage) > 0 {
image = clipImage
}
port := nat.Port("8080/tcp")
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Image: image,
Hostname: Multi2VecCLIP,
Networks: []string{networkName},
NetworkAliases: map[string][]string{
networkName: {Multi2VecCLIP},
},
ExposedPorts: []string{"8080/tcp"},
AutoRemove: true,
WaitingFor: wait.
ForHTTP("/.well-known/ready").
WithPort(port).
WithStatusCodeMatcher(func(status int) bool {
return status == 204
}).
WithStartupTimeout(240 * time.Second),
},
Started: true,
})
if err != nil {
return nil, err
}
uri, err := container.PortEndpoint(ctx, port, "")
if err != nil {
return nil, err
}
envSettings := make(map[string]string)
envSettings["CLIP_INFERENCE_API"] = fmt.Sprintf("http://%s:%s", Multi2VecCLIP, port.Port())
endpoints := make(map[EndpointName]endpoint)
endpoints[HTTP] = endpoint{port, uri}
return &DockerContainer{Multi2VecCLIP, endpoints, container, envSettings}, nil
}
|