Skip to content

Commit aaa7407

Browse files
chore: Improve Docker Compose setup for local development (#182)
* chore: Improve Docker Compose setup for local development - Separate infrastructure containers from module containers for clearer management. - Enable easy scaling of module containers to simulate a production-like setup. Implements: MRSPECS-103
1 parent 82c3c62 commit aaa7407

9 files changed

Lines changed: 572 additions & 55 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Add integration test to cover sync endpoint ([MRSPECS-105](https://folio-org.atlassian.net/browse/MRSPECS-105))
1919
* Add integration test to verify field restoration after sync ([MRSPECS-106](https://folio-org.atlassian.net/browse/MRSPECS-106))
2020
* Refactor code to comply with Checkstyle method length limit (max 25 lines) ([MRSPECS-195](https://folio-org.atlassian.net/browse/MRSPECS-195))
21+
* Improve Docker Compose setup for local development ([MRSPECS-103](https://folio-org.atlassian.net/browse/MRSPECS-103))
2122

2223
### Dependencies
2324
* Bump `LIB_NAME` from `OLD_VERSION` to `NEW_VERSION`

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,58 @@ Change these variables as per your requirements.
6161

6262
### Running The Module
6363

64-
#### Locally
64+
#### Using Docker Compose (Recommended)
6565

66-
Run the module locally on the default listening port (8081) with the prescribed command:
66+
The recommended way to run the module locally is using Docker Compose. This provides a complete development environment with all dependencies.
6767

6868
```shell
69-
DB_HOST=localhost DB_PORT=5432 DB_DATABASE=okapi_modules DB_USERNAME=folio_admin DB_PASSWORD=folio_admin \
70-
java -Dserver.port=8081 -jar mod-record-specifications-server/target/mod-record-specifications-fat.jar
69+
# Build the module JAR
70+
mvn clean package -DskipTests
71+
72+
# Start all services (infrastructure + module)
73+
docker compose -f docker/app-docker-compose.yml up -d
74+
75+
# View logs
76+
docker compose -f docker/app-docker-compose.yml logs -f mod-record-specifications
7177
```
7278

73-
#### Using Docker
79+
For detailed Docker Compose documentation, see [docker/README.md](docker/README.md).
7480

75-
To run the module in a Docker container, first build the Docker image:
81+
#### Local Development with IntelliJ IDEA
7682

77-
```shell
78-
docker build -t dev.folio/mod-record-specifications .
79-
```
83+
For local development, you can run the application directly from IntelliJ IDEA with the `dev` profile. Spring Boot will automatically start the required infrastructure services (PostgreSQL, Kafka) using Docker Compose.
84+
85+
1. Open the project in IntelliJ IDEA
86+
2. Run the main application class with the `dev` profile active
87+
3. Spring Boot will automatically start infrastructure containers from `docker/infra-docker-compose.yml`
88+
89+
#### Manually Running the Module
90+
91+
Run the module locally on the default listening port (8081) with infrastructure services:
8092

81-
Prepare infrastructure needed for the module: PostgreSQL database.
82-
Alternatively, you can use Docker Compose to manage the application's infrastructure.
8393
```shell
84-
docker compose up
94+
# Start infrastructure services
95+
docker compose -f docker/infra-docker-compose.yml up -d
96+
97+
# Run the module
98+
DB_HOST=localhost DB_PORT=5432 DB_DATABASE=okapi_modules DB_USERNAME=folio_admin DB_PASSWORD=folio_admin \
99+
KAFKA_HOST=localhost KAFKA_PORT=29092 \
100+
java -Dserver.port=8081 -jar mod-record-specifications-server/target/mod-record-specifications-fat.jar
85101
```
86102

87-
Then run the container:
103+
#### Using Docker (Legacy)
104+
105+
To run the module in a Docker container:
88106

89107
```shell
90-
docker run -t -i -p 8081:8081 dev.folio/mod-record-specifications
108+
# Build the module JAR
109+
mvn clean package -DskipTests
110+
111+
# Build the Docker image
112+
docker build -t dev.folio/mod-record-specifications .
113+
114+
# Run with Docker Compose
115+
docker compose -f docker/app-docker-compose.yml up -d
91116
```
92117

93118
### Module Descriptor

compose.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

docker/.env

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Docker Compose configuration for mod-record-specifications
2+
3+
# Project name
4+
COMPOSE_PROJECT_NAME=folio-mod-record-specifications
5+
6+
# Module Configuration
7+
ENV=folio
8+
MODULE_REPLICAS=2
9+
10+
# Database Configuration
11+
DB_HOST=postgres
12+
DB_PORT=5432
13+
DB_DATABASE=okapi_modules
14+
DB_USERNAME=folio_admin
15+
DB_PASSWORD=folio_admin
16+
17+
# pgAdmin Configuration
18+
PGADMIN_DEFAULT_EMAIL=user@domain.com
19+
PGADMIN_DEFAULT_PASSWORD=admin
20+
PGADMIN_PORT=5050
21+
22+
# Kafka Configuration
23+
KAFKA_HOST=kafka
24+
KAFKA_PORT=9093
25+
KAFKA_TOPIC_PARTITIONS=2
26+
KAFKA_UI_PORT=8090
27+

0 commit comments

Comments
 (0)