Wednesday, September 17, 2025

+Front end service ->docker-compose.yml (all in one)

Extends the above docker-compose.yml so that it runs backend + Ollama + frontend in one go.  Assumption frontend is a simple Node.js/React app (like a Vite or CRA build). 


✅ docker-compose.yml (with frontend)

version: "3.9"

services:
  backend:
    build: .
    container_name: company-recommender-backend
    ports:
      - "8000:8000"
    environment:
      - OLLAMA_URL=http://ollama:11434
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama

  frontend:
    build: ./frontend   # assumes you have a frontend/ directory
    container_name: company-recommender-frontend
    ports:
      - "3000:3000"
    environment:
      - REACT_APP_API_URL=http://backend:8000   # frontend talks to backend inside Docker
    depends_on:
      - backend

volumes:
  ollama_data:

✅ Frontend Dockerfile (in frontend/Dockerfile)

If your frontend is React (Vite or CRA):

# Use Node.js for building the frontend
FROM node:18-slim

WORKDIR /app

# Install dependencies first
COPY package.json package-lock.json ./
RUN npm install

# Copy all frontend files
COPY . .

# Start dev server (hot reload) or build for production
# For dev mode:
CMD ["npm", "start"]

# For production (static build with Nginx), replace above CMD with:
# RUN npm run build
# FROM nginx:alpine
# COPY --from=0 /app/dist /usr/share/nginx/html
# EXPOSE 80
# CMD ["nginx", "-g", "daemon off;"]

👉 If you want production-ready deployment, I’d recommend the Nginx option (the commented block above), because it’s lighter and faster than running a Node dev server.


✅ Usage

From project root (where docker-compose.yml is):

docker-compose up --build
  • Backend → http://localhost:8000

  • Frontend → http://localhost:3000 (and it calls backend via Docker network using http://backend:8000)

  • Ollama → http://localhost:11434



No comments:

Post a Comment

Document for Docker + nginx + HTTPS setup for Company Recommender

Docker + nginx + HTTPS setup for Company Recommender This document contains a ready-to-use Docker deployment for your FastAPI backend and An...