Sign inSign up

prancodes/blogging-app

By prancodes

•Updated 8 months ago

A full-featured blogging platform built with Spring Boot, Thymeleaf, JPA, and MySQL.

Image
Web servers
Content management system
0

741

prancodes/blogging-app repository overview

⁠BloggingProject šŸ“

A lightweight Spring Boot blogging application containerized for easy deployment. Demonstrates a full CRUD (Create, Read, Update, Delete) flow for articles using Spring Data JPA, Thymeleaf templates, and UUID primary keys stored as BINARY(16).

This project also features fully configured PWA (Progressive Web App) support.


⁠Quick Jump


⁠Prerequisites


⁠Quick Start

⁠Run with Docker

To quickly start the application and its database using Docker, run the following commands.

⁠1. Start MySQL Container
docker run -d \
  --name mysql-blog \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=blogdb \
  -e MYSQL_USER=bloguser \
  -e MYSQL_PASSWORD=password \
  -p 3306:3306 \
  mysql:8.0
⁠2. Start the Blogging Application

Note: The application container is linked to the MySQL container.

docker run -d \
  --name blogging-app \
  -p 8080:8080 \
  -e DB_URL=jdbc:mysql://mysql-blog:3306/blogdb?useSSL=false&serverTimezone=UTC \
  -e DB_USER=bloguser \
  -e DB_PASS=password \
  --link mysql-blog \
  prancodes/blogging-app:latest

⁠Run with Docker Compose

Create a docker-compose.yml file with the following content to orchestrate both services automatically:

version: '3.8'

services:
  app:
    image: prancodes/blogging-app:latest
    container_name: blog-spring-web
    ports:
      - "8080:8080"
    environment:
      - DB_URL=jdbc:mysql://db:3306/blogdb?useSSL=false&serverTimezone=UTC
      - DB_USER=bloguser
      - DB_PASS=password
      - SPRING_PROFILES_ACTIVE=dev
    depends_on:
      - db
    networks:
      - blog-network

  db:
    image: mysql:8.0
    container_name: blog-mysql-db
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=blogdb
      - MYSQL_USER=bloguser
      - MYSQL_PASSWORD=password
    volumes:
      - db-data:/var/lib/mysql
    networks:
      - blog-network

volumes:
  db-data:

networks:
  blog-network:
    driver: bridge

Start the stack:

docker compose up -d

⁠Configuration

⁠Environment Variables

The container is configured using the following environment variables. You can override them at runtime.

VariableDescriptionExample
DB_URLJDBC URL for MySQLjdbc:mysql://host:3306/db...
DB_USERDatabase usernamebloguser
DB_PASSDatabase passwordsecret
SPRING_PROFILES_ACTIVEActive Spring profiledev or prod

⁠✨ Key Features

  • Installable PWA: Fully configured site.webmanifest and Service Worker (sw.js) allow the app to be installed natively on Android, iOS, and Desktop.
  • Complete CRUD Operations: Create, read, update, and delete articles through an intuitive web interface.
  • UUID Primary Keys: Uses Java UUID with Hibernate GenerationType.UUID, optimized as BINARY(16) for performance.
  • Input Validation: Client-side and server-side validation using Jakarta Validation annotations (@NotBlank, @Size).
  • Server-Side Rendering: Built with Spring MVC and Thymeleaf templates for dynamic HTML generation.
  • Profile-Based Configuration: Separate environment configurations for development and production.

ā šŸ› ļø Tech Stack

  • Java 25 (LTS)
  • Spring Boot 4.0.1 (Web, Thymeleaf, Data JPA, Validation)
  • MySQL 8.0
  • Docker & Docker Compose
  • Thymeleaf Templates

⁠Ports

PortDescription
8080Blogging Application Web Interface
3306MySQL Database (if exposed via Compose)

⁠Author

šŸ§‘šŸ»ā€šŸ’» Developed and maintained by Pranjal Singh⁠

Project source code is available on GitHub Repository⁠.

Tag summary

Content type

Image

Digest

sha256:d28479507…

Size

130.4 MB

Last updated

8 months ago

docker pull prancodes/blogging-app