From 99fe65fb5790062239ec0cac9dfb6626695cbdb0 Mon Sep 17 00:00:00 2001 From: kasun Date: Wed, 25 Mar 2026 00:30:21 +0100 Subject: [PATCH] removed docker compose dependency and added dedicated pgvector db --- backend/build.gradle.kts | 2 - backend/compose.yaml | 12 +++-- docs/02-Preparation/02-Spring-Boot-setup.md | 56 ++++++++++++++++++--- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 2b687dd..98739a3 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -33,9 +33,7 @@ dependencies { implementation("org.springframework.ai:spring-ai-starter-model-openai") compileOnly("org.projectlombok:lombok") developmentOnly("org.springframework.boot:spring-boot-devtools") - // developmentOnly("org.springframework.boot:spring-boot-docker-compose") runtimeOnly("org.postgresql:postgresql") - // developmentOnly("org.springframework.ai:spring-ai-spring-boot-docker-compose") annotationProcessor("org.projectlombok:lombok") testImplementation("org.springframework.boot:spring-boot-starter-data-jpa-test") // testImplementation("org.springframework.boot:spring-boot-starter-security-test") diff --git a/backend/compose.yaml b/backend/compose.yaml index 7c8044f..048574f 100644 --- a/backend/compose.yaml +++ b/backend/compose.yaml @@ -1,9 +1,11 @@ services: - postgres: - image: 'postgres:latest' + vaessl-db: + image: 'pgvector/pgvector:pg18' environment: - - 'POSTGRES_DB=mydatabase' - - 'POSTGRES_PASSWORD=secret' - - 'POSTGRES_USER=myuser' + - 'POSTGRES_DB=vaessl' + - 'POSTGRES_PASSWORD=password' + - 'POSTGRES_USER=user' ports: - '5432' + labels: + - "org.springframework.boot.service-connection=postgres" diff --git a/docs/02-Preparation/02-Spring-Boot-setup.md b/docs/02-Preparation/02-Spring-Boot-setup.md index bac863b..1c3fcf3 100644 --- a/docs/02-Preparation/02-Spring-Boot-setup.md +++ b/docs/02-Preparation/02-Spring-Boot-setup.md @@ -2,7 +2,7 @@ This app will use the current latest version 4.0.4 of Spring Boot and the latest OpenJDK 25 LTS. - The dependencies are chosen to specifically work with Spring AI, PostgreSQL and Docker. For the AI function OpenAI is chosen since it is known to work with LiteLLM. The PostgreSQL dependency makes sure to include PostGreSQL support for self hosted databases. Docker Compose makes sure to handle future Docker implementations. + The dependencies are chosen to specifically work with Spring AI and PostgreSQL/pgvector. For the AI function OpenAI is chosen since it is known to work with LiteLLM. The PostgreSQL dependency makes sure to include PostGreSQL support for self hosted databases. # Spring Initializr settings @@ -22,7 +22,6 @@ Gradel Kotlin is chosen to make mobile/Android app development easier. - Lombok - Spring Boot DevTools -- Docker Compose Support - Spring Web - Spring Security - Spring Data JPA @@ -32,7 +31,7 @@ Gradel Kotlin is chosen to make mobile/Android app development easier. # Project Settings -Docker Compose, PostGreSQL and OpenAI need an initial setup so that the local instance is able to start. Since I will handle Docker issues later I will comment the dependencies out for now. I will also comment out Spring Security since user management is an issue for a later iteration of the app. +PostGreSQL and OpenAI need an initial setup so that the local instance is able to start. I will comment out Spring Security since user management is an issue for a later iteration of the app. The build.gradle.kts will look something like this: @@ -72,9 +71,7 @@ dependencies { implementation("org.springframework.ai:spring-ai-starter-model-openai") compileOnly("org.projectlombok:lombok") developmentOnly("org.springframework.boot:spring-boot-devtools") - // developmentOnly("org.springframework.boot:spring-boot-docker-compose") runtimeOnly("org.postgresql:postgresql") - // developmentOnly("org.springframework.ai:spring-ai-spring-boot-docker-compose") annotationProcessor("org.projectlombok:lombok") testImplementation("org.springframework.boot:spring-boot-starter-data-jpa-test") // testImplementation("org.springframework.boot:spring-boot-starter-security-test") @@ -98,7 +95,7 @@ tasks.withType { To configure OpenAI (which I will use instead of LiteLLM initially since I have an OpenAI Api key and can get going quickly) and PostGreSQL I will create a .env_dev file in the root dir, fill all credentials and add it to .gitignore ``` -DB_URL=jdbc:postgresql://192.168.1.208:5432/vaessl-playground +DB_URL=jdbc:postgresql://192.168.1.208:5433/vaessl DB_USERNAME=myusername DB_PASSWORD=mypw OPENAI_KEY=myapikey @@ -139,7 +136,52 @@ spring: ``` -Note that I'm using my own locally hosted PostgreSQL instance here and created a dedicated db for this project. There is a Docker Compose config with the Spring Boot dependency for this but since my DB is always on and running independently I don't need the Docker Compose management. +Note that I'm using my own locally hosted PostgreSQL instance here and created a dedicated db for this project. The Docker Compose file will look something like this: + +``` +--- +services: + code-server: + image: code-server-dev:latest + container_name: code-server + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Vienna +# - PASSWORD= #optional + - HASHED_PASSWORD=hashedpw +# - SUDO_PASSWORD_HASH= #optional + - PROXY_DOMAIN=code-server.your.website + - DEFAULT_WORKSPACE=/config/workspace + volumes: + - /home/pi/docker/vscode:/config + - /home/pi/docker/vscode/workspace:/workspace + ports: + - 8443:8443 + - 8124:8080 + - 5173:5173 + restart: unless-stopped + + vaessl-db: + image: pgvector/pgvector:pg18 + container_name: vaessl-db + environment: + - POSTGRES_DB=vaessl + - POSTGRES_USER=user + - POSTGRES_PASSWORD=pw + ports: + - 5433:5432 + + vassal-test-db: + image: pgvector/pgvector:pg18 + container_name: vassal-test-db + environment: + - POSTGRES_DB=vassal_test + - POSTGRES_USER=user + - POSTGRES_PASSWORD=pw + ports: + - 5434:5432 +``` # Appendix: Additional config for developing in Code-Server