https://github.com/cyrillesaga/spring-postgres-docker
This project is a simple Spring Boot application that demonstrates how to use Docker and Docker Compose to run a Spring Boot application with a PostgreSQL database.
https://github.com/cyrillesaga/spring-postgres-docker
boot containers docker docker-compose image java postgresql spring template
Last synced: 2 months ago
JSON representation
This project is a simple Spring Boot application that demonstrates how to use Docker and Docker Compose to run a Spring Boot application with a PostgreSQL database.
- Host: GitHub
- URL: https://github.com/cyrillesaga/spring-postgres-docker
- Owner: CyrilleSaga
- Created: 2025-02-27T20:45:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-27T20:49:31.000Z (over 1 year ago)
- Last Synced: 2025-02-28T05:32:40.823Z (over 1 year ago)
- Topics: boot, containers, docker, docker-compose, image, java, postgresql, spring, template
- Language: Java
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot Docker Demo
This project is a simple Spring Boot application that demonstrates how to use Docker and Docker Compose to run a Spring Boot application with a PostgreSQL database.
## Prerequisites
- Docker
- Docker Compose
- Java 21
- Maven
## Project Structure
- `src/main/java/com/demo/docker/controllers/TestController.java`: Contains the REST API endpoints.
- `docker-compose.yml`: Defines the Docker services for the application and PostgreSQL database.
- `Dockerfile`: Builds the Docker image for the Spring Boot application.
## Running the Application
1. **Build the Docker images:**
```sh
docker-compose build
```
2. **Start the services:**
```sh
docker-compose up
```
3. The Spring Boot application will be available at `http://localhost:8080`.
## API Endpoints
- **POST /**: Create a new test entity.
- **GET /**: Retrieve all test entities.
- **GET /{id}**: Retrieve a test entity by its ID.
- **DELETE /delete/{id}**: Delete a test entity by its ID.
## Configuration
The application uses the following environment variables for database configuration:
- `SPRING_DATASOURCE_URL`
- `SPRING_DATASOURCE_USERNAME`
- `SPRING_DATASOURCE_PASSWORD`
These are set in the `docker-compose.yml` file.
## Building and Running Locally
To build and run the application locally without Docker:
1. **Build the project:**
```sh
mvn clean package
```
2. **Run the application:**
```sh
java -jar target/*.jar
```
## License
This project is licensed under the MIT License.