{"id":30362453,"url":"https://github.com/dlsnemsara/dockerized-spring-todo-api","last_synced_at":"2026-04-05T23:03:59.361Z","repository":{"id":310630891,"uuid":"1040459043","full_name":"DLSNemsara/dockerized-spring-todo-api","owner":"DLSNemsara","description":"A production-ready, containerized To-Do API built with Spring Boot. Features a multi-stage Dockerfile, Docker volumes for persistent data, and a custom bridge network for communication.","archived":false,"fork":false,"pushed_at":"2025-08-19T08:39:41.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-19T10:44:20.479Z","etag":null,"topics":["containerization","docker","docker-networking","docker-volumes","java","logback","maven","multi-stage-build","postgresql","rest-api","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DLSNemsara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-19T02:38:31.000Z","updated_at":"2025-08-19T08:39:44.000Z","dependencies_parsed_at":"2025-08-19T10:44:23.226Z","dependency_job_id":"1bcde754-6d97-4293-b8b3-738178459fbd","html_url":"https://github.com/DLSNemsara/dockerized-spring-todo-api","commit_stats":null,"previous_names":["dlsnemsara/dockerized-spring-todo-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/DLSNemsara/dockerized-spring-todo-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLSNemsara%2Fdockerized-spring-todo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLSNemsara%2Fdockerized-spring-todo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLSNemsara%2Fdockerized-spring-todo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLSNemsara%2Fdockerized-spring-todo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DLSNemsara","download_url":"https://codeload.github.com/DLSNemsara/dockerized-spring-todo-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLSNemsara%2Fdockerized-spring-todo-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271190252,"owners_count":24715144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containerization","docker","docker-networking","docker-volumes","java","logback","maven","multi-stage-build","postgresql","rest-api","spring-boot"],"created_at":"2025-08-19T17:14:33.527Z","updated_at":"2025-12-30T21:42:33.999Z","avatar_url":"https://github.com/DLSNemsara.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockerized Spring Boot Todo API\n\n## Project Description\nThis project is a RESTful API for a simple Todo application, built with Spring Boot and containerized with Docker. The primary goal is to showcase a practical implementation of cloud-native principles, including a multi-stage Docker build, persistent data storage using volumes, and seamless inter-container communication on a custom Docker network.\n\nThis project was developed as a learning exercise provided by **Cloud Native Sri Lanka** to demonstrate core DevOps skills.\n\n***\n\n## Features\n- **Full CRUD Functionality**: Create, Read, Update, and Delete operations for Todo items.\n- **Optimized Docker Build**: A multi-stage Dockerfile ensures a lightweight and secure production image.\n- **Persistent Logging**: Application logs are written to a named Docker volume (`/var/log/app`), ensuring they survive container restarts.\n- **Containerized Database**: A PostgreSQL container serves as the database, with its data persisted in a separate named volume.\n- **Custom Networking**: The Spring Boot API and PostgreSQL database communicate efficiently and securely over a custom user-defined bridge network.\n- **Interactive API Documentation**: Swagger UI is now available via Springdoc OpenAPI, allowing developers to explore and test all API endpoints interactively.\n\n\n***\n\n## Tech Stack\n\n| Category            | Technology                  |\n|---------------------|-----------------------------|\n| Language \u0026 Framework| Java 17, Spring Boot 3.5    |\n| Build Tool          | Maven                       |\n| Containerization    | Docker, Docker Compose      |\n| Database            | PostgreSQL                  |\n| Logging             | Logback                     |\n\n***\n\n## Architecture Overview\nThis application uses a simple, multi-container architecture managed by Docker Compose.\n\n- The **Spring Boot App container** runs the Java API.\n- The **PostgreSQL DB container** stores the application data.\n- Both containers are connected to a custom bridge network named `todo-network`, allowing them to communicate via their service names (`app` and `db`).\n- Two named volumes, `app-logs` and `db-data`, are used to persist logs and database information.\n\n***\n\n## Getting Started\n\n### Prerequisites\n- Docker Desktop\n- Java 17+\n- Maven\n\n### Running the Application\n\n**Clone the Repository**\n```bash\ngit clone https://github.com/your-username/dockerized-spring-todo-api.git\ncd dockerized-spring-todo-api\n```\n\n**Build and Run with Docker Compose**  \nThis command will build the Spring Boot application image and start both the application and database containers in detached mode.\n\n```bash\ndocker compose up -d --build\n```\n\n**Verify the Containers are Running**\n\n```bash\ndocker compose ps\n```\n\nYou should see two containers (`app` and `db`) with a status of \"Up\".\n\n**Access the API**  \nThe API will be available at [http://localhost:8080](http://localhost:8080).\n\n**Access Swagger UI**\n\nInteractive API documentation is available at: [http://localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html)\n\n-----\n\n## API Endpoints\n\nYou can use a tool like Postman or `curl` to interact with the API.\n\n| Method | Endpoint         | Description                 |\n|--------|------------------|-----------------------------|\n| GET    | `/api/todos`     | Retrieve all todos.         |\n| GET    | `/api/todos/{id}`| Retrieve a single todo.     |\n| POST   | `/api/todos`     | Create a new todo.          |\n| PUT    | `/api/todos/{id}`| Update an existing todo.    |\n| DELETE | `/api/todos/{id}`| Delete a todo.              |\n\n**Example: Create a New Todo with curl**\n\n```bash\ncurl -X POST http://localhost:8080/api/todos \\\n-H \"Content-Type: application/json\" \\\n-d '{\"title\": \"Configure Kubernetes cluster for rolling updates and autoscaling\", \"done\": false}'\n```\n💡 All endpoints are fully documented and can be tested directly via Swagger UI.\n\n-----\n\n## Reflection on Learning\n\nThis project was a practical deep-dive into two fundamental Docker concepts: persistent storage and networking. Using named volumes proved to be a straightforward yet powerful way to decouple a container's lifecycle from the data it generates, ensuring that critical information like logs and database files persists across restarts.\n\nThe real insight came from implementing a custom bridge network, which abstracts away container IP addresses and allows services to communicate securely using their defined names. This approach simplifies configuration and is a foundational pattern for building scalable, multi-service applications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlsnemsara%2Fdockerized-spring-todo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlsnemsara%2Fdockerized-spring-todo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlsnemsara%2Fdockerized-spring-todo-api/lists"}