Artificial Intelligence 12 min read

Deploying a Local High‑Performance AI Service with Spring AI, Ollama, Redis, and Docker

This tutorial walks developers through setting up a low‑cost, containerized AI service on Windows by installing Docker, deploying Redis and Ollama containers, pulling the DeepSeek‑R1 model, and integrating everything with Spring AI to enable continuous conversation support.

Architect's Guide
Architect's Guide
Architect's Guide
Deploying a Local High‑Performance AI Service with Spring AI, Ollama, Redis, and Docker

In the era of rapidly spreading large‑model technology, the article explains how to build a private, low‑cost AI service that runs locally and supports continuous dialogue.

Environment preparation : Windows 11, JDK 17+, Maven 3.8.3+, Docker installed and verified with docker ps .

Docker & Redis deployment : Pull Redis image with docker pull redis:7.4.2 , create configuration files under C:\docker\redis\conf and C:\docker\redis\data , then run the container: docker run -d \ -p 6579:6379 \ -v C:/docker/redis/data:/data \ -v C:/docker/redis/conf:/usr/local/etc/redis \ --name redis \ redis:7.4.2 redis-server /usr/local/etc/redis/redis.conf

Ollama installation : Pull Ollama image with docker pull ollama/ollama:0.6.2 , create C:\docker\ollama directory and start the container: docker run -d \ -v C:\docker\ollama:/root/.ollama \ -p 11434:11434 \ --name ollama \ ollama/ollama:0.6.2

DeepSeek‑R1 model pull : Inside the Ollama container execute docker exec -it ollama ollama pull deepseek-r1:7b to download the 7B model.

Spring AI integration :

Core Maven dependencies (Spring Boot 3.4.3, Spring AI 1.0.0‑M6, Lombok, Redis starter) are defined in the pom.xml snippet.

application.yml configures server port, Redis connection (host 127.0.0.1, port 6579, password 123123) and Ollama base URL with the DeepSeek model.

Controller OllamaChatController.java exposes /ai/v1/ollama/redis/chat to handle user queries, using ChatClient and ChatMemory for context.

Custom ChatRedisMemory.java implements ChatMemory to persist conversation history in Redis lists.

RedisConfig.java creates a RedisTemplate with JSON serialization.

Entity ChatEntity.java stores chat ID, type, and text.

Main class OllamaChatDemoApplication.java boots the Spring application.

Testing & verification : After starting Docker containers and the Spring service (port 8083), send requests to http://127.0.0.1:8083/ai/v1/ollama/redis/chat?userId=xxx&input=... . The article shows sample queries and screenshots of responses and Redis stored data.

Conclusion : By combining Docker, Redis, Ollama, and Spring AI, developers can quickly spin up a private AI service that supports continuous conversations, offering a cost‑effective solution for internal knowledge bases or educational Q&A systems.

JavaDockerRedisMavenAI deploymentSpring AIOllama
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.