Skip to content

fcesur/spring-boot-docker-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Docker Compose Demo

This project demonstrates how to containerize a Spring Boot application using Docker and Docker Compose, with a PostgreSQL database.

Prerequisites

Getting Started

1. Clone the Repository

git clone <repository-url>

2. Create a .env File

Create a .env file in the project root with the following content:

POSTGRES_DB=testDB
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

You can change these values as needed, but make sure they match the configuration in application.properties and docker-compose.yaml.

3. Build and Run with Docker Compose

docker compose up --build
  • The Spring Boot app will be available at http://localhost:8085
  • PostgreSQL will be available at localhost:5432

4. Stopping the Application

docker compose down

Project Structure

  • Dockerfile - Multi-stage build for Spring Boot app
  • docker-compose.yaml - Defines services for the app and PostgreSQL
  • init/init.sql - SQL script to initialize the database
  • src/ - Application source code

Notes

  • The application uses environment variables for database configuration.
  • The database is initialized with sample data from init/init.sql.

That's all!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published