Sign inSign up

lahirudilhara/webchat-backend

By lahirudilhara

•Updated about 1 year ago

Image
0

454

lahirudilhara/webchat-backend repository overview

⁠WebChat Backend Docker Image

⁠Overview

This Docker image provides the backend for the WebChat application, built with Spring Boot.

The backend handles:

  • User management – create, update, delete users
  • Room management – create and manage chat rooms
  • Message management – store and retrieve messages
  • Real-time communication – WebSocket support for instant messaging
  • Integration with PostgreSQL and Redis – persistence and caching

The image is designed to be environment-agnostic, with all database and cache configurations provided via environment variables, making it easy to deploy in Docker Compose or Docker Swarm.


⁠Features

  • REST API endpoints for users, rooms, and messages
  • WebSocket endpoints for real-time chat
  • PostgreSQL-backed persistence for reliable storage
  • Redis-based caching for fast message retrieval and session handling
  • Configurable via environment variables — no need to rebuild the image for different environments

⁠Environment Variables

The following environment variables must be set when running the container:

VariableDescriptionExample
SPRING_DATASOURCE_URLJDBC URL for PostgreSQL databasejdbc:postgresql://postgres:5432/webchat
SPRING_DATASOURCE_USERNAMEPostgreSQL usernamewebchat_user
SPRING_DATASOURCE_PASSWORDPostgreSQL passwordsecret
SPRING_CACHE_TYPECache type for Spring Bootredis
SPRING_DATA_REDIS_HOSTRedis server hostredis
SPRING_DATA_REDIS_PORTRedis server port6379
SPRING_PROFILES_ACTIVESpring profile (optional, e.g., prod/dev)prod

Example: These can be set via Docker Compose, environment files, or Docker Swarm secrets.


⁠Example Docker Compose

version: "3.9"
services:
  backend:
    image: lahiru/webchat-backend:v1.0
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/webchat
      - SPRING_DATASOURCE_USERNAME=webchat_user
      - SPRING_DATASOURCE_PASSWORD=secret
      - SPRING_CACHE_TYPE=redis
      - SPRING_DATA_REDIS_HOST=redis
      - SPRING_DATA_REDIS_PORT=6379
    ports:
      - "8080:8080"
    depends_on:
      - postgres
      - redis

  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_DB=webchat
      - POSTGRES_USER=webchat_user
      - POSTGRES_PASSWORD=secret
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

volumes:
  pgdata:

Tag summary

Content type

Image

Digest

sha256:120aa57cc…

Size

171.4 MB

Last updated

about 1 year ago

docker pull lahirudilhara/webchat-backend