github.com/weaviate/weaviate@v1.24.6/test/docker/contextionary.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package docker 13 14 import ( 15 "context" 16 "fmt" 17 18 "github.com/docker/go-connections/nat" 19 "github.com/testcontainers/testcontainers-go" 20 "github.com/testcontainers/testcontainers-go/wait" 21 ) 22 23 const Text2VecContextionary = "text2vec-contextionary" 24 25 func startT2VContextionary(ctx context.Context, networkName, contextionaryImage string) (*DockerContainer, error) { 26 image := "semitechnologies/contextionary:en0.16.0-v1.2.1" 27 if len(contextionaryImage) > 0 { 28 image = contextionaryImage 29 } 30 port := nat.Port("9999/tcp") 31 container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ 32 ContainerRequest: testcontainers.ContainerRequest{ 33 Image: image, 34 Hostname: Text2VecContextionary, 35 Networks: []string{networkName}, 36 NetworkAliases: map[string][]string{ 37 networkName: {Text2VecContextionary}, 38 }, 39 Name: Text2VecContextionary, 40 Env: map[string]string{ 41 "OCCURRENCE_WEIGHT_LINEAR_FACTOR": "0.75", 42 "EXTENSIONS_STORAGE_MODE": "weaviate", 43 "EXTENSIONS_STORAGE_ORIGIN": fmt.Sprintf("http://%s:8080", Weaviate), 44 }, 45 ExposedPorts: []string{"9999/tcp"}, 46 AutoRemove: true, 47 WaitingFor: wait.ForListeningPort(port), 48 }, 49 Started: true, 50 Reuse: true, 51 }) 52 if err != nil { 53 return nil, err 54 } 55 uri, err := container.PortEndpoint(ctx, port, "") 56 if err != nil { 57 return nil, err 58 } 59 envSettings := make(map[string]string) 60 envSettings["CONTEXTIONARY_URL"] = fmt.Sprintf("%s:%s", Text2VecContextionary, port.Port()) 61 endpoints := make(map[EndpointName]endpoint) 62 endpoints[HTTP] = endpoint{port, uri} 63 return &DockerContainer{Text2VecContextionary, endpoints, container, envSettings}, nil 64 }