File size: 2,678 Bytes
d7f1ba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: SimpleJavaApp
emoji: πŸš€
colorFrom: blue
colorTo: green
sdk: docker
app_port: 8080
pinned: false
---

# SimpleJavaApp πŸš€

A modern and production-ready Spring Boot application containerized for easy, free cloud deployment (Render, Koyeb, OCI) .

This project features a fully configured **Student Management Service** and comes out of the box with Docker multi-stage build optimization and automated JVM memory tuning specifically designed to prevent Out of Memory (OOM) errors on restricted free-tier hosting platforms.

---

## 🌟 Key Features

* **Spring Boot Core**: Web, JPA, H2 In-Memory database, and custom library starter support.
* **REST APIs**: Full CRUD capabilities for student resource management.
* **Self-Contained Dependency Management**: Houses the custom `spring-boot-mcp-starter` library locally in `/libs` so that the cloud build compiles flawlessly without external repositories.
* **Cloud-Optimized Dockerfile**: Uses a multi-stage `eclipse-temurin` Alpine Docker image to produce a ultra-lightweight running container.
* **Smart JVM Memory Constraints**: Automatically restricts JVM heap space to `75%` of container memory to survive restricted hosting tiers.

---

## πŸ› οΈ How to Run Locally

### Prerequisites
* **Java SDK**: Version 21
* **Gradle**: Handled automatically via `./gradlew`

### Run from Terminal
Clone the repository and run:
```bash
# Run the application
./gradlew bootRun
```
The application will start on `http://localhost:8080`.

---

## ☁️ How to Deploy Free on the Cloud (Render)

This application is ready to deploy to **Render** with a single click.

1. **Push your code to GitHub**: Create a repository and push this project directory.
2. **Log into Render**: Connect using your GitHub account at [Render Dashboard](https://dashboard.render.com).
3. **Create a New Web Service**:
   * Click **New +** > **Web Service**.
   * Select your `SimpleJavaApp` repository.
4. **Configure Settings**:
   * **Runtime**: `Docker`
   * **Instance Type**: `Free`
5. **Launch**: Click **Create Web Service**. 

Render will automatically read the `Dockerfile`, package the local libraries, compile your source code, and serve it live!

---

## πŸ“ Project Structure

```text
β”œβ”€β”€ libs/                    # Local jar dependencies (spring-boot-mcp-starter)
β”œβ”€β”€ src/                     # Application source code
β”‚   └── main/java/com/...    # Spring controllers, services, repositories
β”œβ”€β”€ Dockerfile               # High-efficiency multi-stage Docker build
β”œβ”€β”€ build.gradle             # Build and dependency configuration
└── README.md                # Project documentation
```