Skip to content

Commit

Permalink
Add Weaviate Docker Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed May 28, 2024
1 parent b327872 commit 6ece929
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.spring.initializr.generator.buildsystem.Build;
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency;
import io.spring.start.site.container.ComposeFileCustomizer;
import io.spring.start.site.container.DockerServiceResolver;
import io.spring.start.site.container.ServiceConnections.ServiceConnection;
import io.spring.start.site.container.ServiceConnectionsCustomizer;
Expand Down Expand Up @@ -48,4 +49,14 @@ ServiceConnectionsCustomizer weaviateServiceConnectionsCustomizer(Build build,
};
}

@Bean
@ConditionalOnRequestedDependency("docker-compose")
ComposeFileCustomizer weaviateComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) {
return (composeFile) -> {
if (SpringAiVersion.version1OrLater(build)) {
serviceResolver.doWith("weaviate", (service) -> composeFile.services().add("weaviate", service));
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.spring.start.site.extension.dependency.springai;

import io.spring.initializr.generator.test.project.ProjectStructure;
import io.spring.initializr.web.project.ProjectRequest;
import io.spring.start.site.extension.AbstractExtensionTests;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for {@link SpringAiWeaviateProjectGenerationConfiguration}
*
* @author Eddú Meléndez
*/
class SpringAiWeaviateProjectGenerationConfigurationTests extends AbstractExtensionTests {

@Test
void doesNothingWithoutDockerCompose() {
ProjectRequest request = createProjectRequest("web", "spring-ai-vectordb-qdrant");
ProjectStructure structure = generateProject(request);
assertThat(structure.getProjectDirectory().resolve("compose.yaml")).doesNotExist();
}

@Test
void createsWeaviateService() {
ProjectRequest request = createProjectRequest("docker-compose", "spring-ai-vectordb-weaviate");
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/weaviate.yaml"));
}

}
5 changes: 5 additions & 0 deletions start-site/src/test/resources/compose/weaviate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
weaviate:
image: 'semitechnologies/weaviate'
ports:
- '8080'

0 comments on commit 6ece929

Please sign in to comment.