From 194d1cc7e86447747a4c2814559c5b00b4271d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 27 Nov 2025 14:21:54 +0100 Subject: [PATCH 1/5] feature/Copying recursively might inadvertently add sensitive data to the container. SonarQube security warning by: ## Summary of Changes ### 1. **Selective File Copying in Dockerfile** Instead of using `COPY . .` which copies everything recursively, I've updated the Dockerfile to explicitly copy only the necessary files and directories: - **Maven configuration**: `pom.xml`, `build.sbt` - **Source code directories**: `obp-api/`, `obp-commons/`, `project/` - **Required build files**: `jitpack.yml`, `web-app_2_3.dtd` ### 2. **Enhanced .dockerignore** I've significantly expanded the `.dockerignore` file to exclude: - **IDE files**: `.idea/`, `.vscode/`, `.metals/`, etc. - **Build artifacts**: `target/`, `cache/`, Maven local repository - **Sensitive files**: Environment files, keys, certificates, passwords - **OS files**: `.DS_Store`, thumbnails, etc. - **Documentation**: Most markdown files (keeping license files) - **Development files**: `ideas/`, `resourcedoc/` ## Security Benefits 1. **Reduced attack surface**: Only necessary files are included in the Docker image 2. **No accidental secrets**: Explicit exclusion of common sensitive file patterns 3. **Smaller image size**: Excluding unnecessary files reduces image size 4. **Better maintainability**: Clear understanding of what goes into the container ## Build Compatibility The changes maintain full Maven build compatibility by ensuring all necessary files for the build process are still copied: - Maven POM files for dependency management - Source code directories - Build configuration files - The entrypoint script (specifically allowed in .dockerignore) This approach follows Docker security best practices and addresses the SonarQube warning while maintaining the functionality of your build process. --- .dockerignore | 67 ++++++++++++++++++++++++++++++++++++++++++++++- docker/Dockerfile | 16 ++++++++--- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 28fb10712f..c5571b0216 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,68 @@ +# Existing configuration exclusions obp-api/src/main/resources/props/* !obp-api/src/main/resources/props/sample.props.template -!obp-api/src/main/resources/props/test.default.props.template \ No newline at end of file +!obp-api/src/main/resources/props/test.default.props.template + +# IDE and editor files +.idea/ +.vscode/ +.metals/ +.bloop/ +.run/ +.zed/ +zed/ + +# Build artifacts and caches +target/ +cache/ +~/.m2/ + +# Git and version control +.git/ +.gitignore + +# Environment and secret files +.env +.env.* +*.key +*.pem +*.p12 +*.jks +*secret* +*password* + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Log files +*.log +logs/ + +# Temporary files +*.tmp +*.temp +*.swp +*.swo +*~ + +# Documentation and non-essential files (keep essential ones) +README.md +*.md +!NOTICE +!GNU_AFFERO_GPL_V3_19_Nov_1997.txt +!Harmony_Individual_Contributor_Assignment_Agreement.txt + +# Docker files themselves (avoid recursive copies) +Dockerfile +docker/ +!docker/entrypoint.sh + +# Test and development files +ideas/ +resourcedoc/ \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 53a999d1dc..e4d6dd6e62 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,8 +2,18 @@ FROM maven:3.9.6-eclipse-temurin-17 WORKDIR /app -# Copy all project files into container -COPY . . +# Copy Maven configuration files +COPY pom.xml . +COPY build.sbt . + +# Copy source code and necessary project files +COPY obp-api/ ./obp-api/ +COPY obp-commons/ ./obp-commons/ +COPY project/ ./project/ + +# Copy other necessary files for the build +COPY jitpack.yml . +COPY web-app_2_3.dtd . EXPOSE 8080 @@ -15,4 +25,4 @@ COPY docker/entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh # Use script as entrypoint -CMD ["/app/entrypoint.sh"] +CMD ["/app/entrypoint.sh"] \ No newline at end of file From 72dca46865d453a11be517fead1c485451ab71cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 27 Nov 2025 15:42:03 +0100 Subject: [PATCH 2/5] feature/Move docker to the development folder --- .dockerignore | 9 +++++--- Dockerfile => development/docker/Dockerfile | 0 .../docker/Dockerfile.dev | 2 +- {docker => development/docker}/README.md | 0 .../docker/docker-compose.override.yml | 7 +++++++ development/docker/docker-compose.yml | 21 +++++++++++++++++++ {docker => development/docker}/entrypoint.sh | 0 docker/docker-compose.override.yml | 7 ------- docker/docker-compose.yml | 14 ------------- 9 files changed, 35 insertions(+), 25 deletions(-) rename Dockerfile => development/docker/Dockerfile (100%) rename docker/Dockerfile => development/docker/Dockerfile.dev (91%) rename {docker => development/docker}/README.md (100%) create mode 100644 development/docker/docker-compose.override.yml create mode 100644 development/docker/docker-compose.yml rename {docker => development/docker}/entrypoint.sh (100%) delete mode 100644 docker/docker-compose.override.yml delete mode 100644 docker/docker-compose.yml diff --git a/.dockerignore b/.dockerignore index c5571b0216..ce7b14d46d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,10 @@ -# Existing configuration exclusions +# Configuration files - exclude potentially sensitive props but allow templates and default configs obp-api/src/main/resources/props/* !obp-api/src/main/resources/props/sample.props.template !obp-api/src/main/resources/props/test.default.props.template +!obp-api/src/main/resources/props/test.default.props +!obp-api/src/main/resources/props/default.props +!obp-api/src/main/resources/props/development.default.props # IDE and editor files .idea/ @@ -60,8 +63,8 @@ README.md # Docker files themselves (avoid recursive copies) Dockerfile -docker/ -!docker/entrypoint.sh +development/docker/ +!development/docker/entrypoint.sh # Test and development files ideas/ diff --git a/Dockerfile b/development/docker/Dockerfile similarity index 100% rename from Dockerfile rename to development/docker/Dockerfile diff --git a/docker/Dockerfile b/development/docker/Dockerfile.dev similarity index 91% rename from docker/Dockerfile rename to development/docker/Dockerfile.dev index e4d6dd6e62..d24ca0f644 100644 --- a/docker/Dockerfile +++ b/development/docker/Dockerfile.dev @@ -21,7 +21,7 @@ EXPOSE 8080 RUN mvn install -pl .,obp-commons -am -DskipTests # Copy entrypoint script that runs mvn with needed JVM flags -COPY docker/entrypoint.sh /app/entrypoint.sh +COPY development/docker/entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh # Use script as entrypoint diff --git a/docker/README.md b/development/docker/README.md similarity index 100% rename from docker/README.md rename to development/docker/README.md diff --git a/development/docker/docker-compose.override.yml b/development/docker/docker-compose.override.yml new file mode 100644 index 0000000000..5c2291bf36 --- /dev/null +++ b/development/docker/docker-compose.override.yml @@ -0,0 +1,7 @@ +version: "3.8" + +services: + obp-api: + volumes: + - ../../obp-api:/app/obp-api + - ../../obp-commons:/app/obp-commons diff --git a/development/docker/docker-compose.yml b/development/docker/docker-compose.yml new file mode 100644 index 0000000000..6099f36269 --- /dev/null +++ b/development/docker/docker-compose.yml @@ -0,0 +1,21 @@ +version: "3.8" + +services: + obp-api: + build: + context: ../.. + dockerfile: development/docker/Dockerfile + ports: + - "8080:8080" + environment: + # Set Lift props location to find your props files + - props.resource.dir=/app/props/ + - JAVA_OPTS=-Drun.mode=production -Dprops.resource.dir=/app/props/ + volumes: + # Mount the props directory so the container uses your local props files + - ../../obp-api/src/main/resources/props:/app/props + extra_hosts: + # Connect to local Postgres on the host + # In your config file: + # db.url=jdbc:postgresql://host.docker.internal:5432/YOUR_DB?user=YOUR_DB_USER&password=YOUR_DB_PASSWORD + - "host.docker.internal:host-gateway" diff --git a/docker/entrypoint.sh b/development/docker/entrypoint.sh similarity index 100% rename from docker/entrypoint.sh rename to development/docker/entrypoint.sh diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml deleted file mode 100644 index 80e973a2cd..0000000000 --- a/docker/docker-compose.override.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: "3.8" - -services: - obp-api: - volumes: - - ../obp-api:/app/obp-api - - ../obp-commons:/app/obp-commons diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index ca4eda42a0..0000000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: "3.8" - -services: - obp-api: - build: - context: .. - dockerfile: docker/Dockerfile - ports: - - "8080:8080" - extra_hosts: - # Connect to local Postgres on the host - # In your config file: - # db.url=jdbc:postgresql://host.docker.internal:5432/YOUR_DB?user=YOUR_DB_USER&password=YOUR_DB_PASSWORD - - "host.docker.internal:host-gateway" From 141f2d666f2f5a6ab6fdf3db82127f5433cc4dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 27 Nov 2025 16:37:16 +0100 Subject: [PATCH 3/5] feature/Move docker to the development folder 2 --- development/docker/.env | 17 +++ development/docker/README.md | 206 ++++++++++++++++++++------ development/docker/docker-compose.yml | 33 +++++ 3 files changed, 207 insertions(+), 49 deletions(-) create mode 100644 development/docker/.env diff --git a/development/docker/.env b/development/docker/.env new file mode 100644 index 0000000000..9f031eb4c3 --- /dev/null +++ b/development/docker/.env @@ -0,0 +1,17 @@ +# Docker Compose Environment Configuration for OBP-API Development + +# Redis Configuration +# Set custom Redis port (externally exposed port) +# The Redis container will be accessible on this port from the host machine +# Default is 6380 to avoid conflicts with local Redis on 6379 +OBP_CACHE_REDIS_PORT=6380 + +# Database Configuration +# Set custom database URL for Docker environment +# Default connects to host PostgreSQL via host.docker.internal +OBP_DB_URL=jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=f + +# You can override these by setting environment variables: +# export OBP_CACHE_REDIS_PORT=6381 +# export OBP_DB_URL="jdbc:postgresql://host.docker.internal:5432/mydb?user=myuser&password=mypass" +# docker-compose up --build \ No newline at end of file diff --git a/development/docker/README.md b/development/docker/README.md index 1c46f09e0e..97d1897dcc 100644 --- a/development/docker/README.md +++ b/development/docker/README.md @@ -1,96 +1,204 @@ -## OBP API – Docker & Docker Compose Setup +# OBP-API Docker Development Setup -This project uses Docker and Docker Compose to run the **OBP API** service with Maven and Jetty. +This Docker Compose setup provides a complete development environment for OBP-API with Redis caching support. -- Java 17 with reflection workaround -- Connects to your local Postgres using `host.docker.internal` -- Supports separate dev & prod setups +## Services ---- +### 🏦 **obp-api-app** +- Main OBP-API application +- Built with Maven 3 + OpenJDK 17 +- Runs on Jetty 9.4 +- Port: `8080` + +### πŸ”΄ **obp-api-redis** +- Redis cache server +- Version: Redis 7 Alpine +- Internal port: `6379` +- External port: `6380` (configurable) +- Persistent storage with AOF + +## Quick Start -## How to use +1. **Prerequisites** + - Docker and Docker Compose installed + - Local PostgreSQL database running + - Props file configured at `obp-api/src/main/resources/props/default.props` -> **Make sure you have Docker and Docker Compose installed.** +2. **Start services** + ```bash + cd development/docker + docker-compose up --build + ``` -### Set up the database connection +3. **Access application** + - OBP-API: http://localhost:8080 + - Redis: `localhost:6380` -Edit your `default.properties` (or similar config file): +## Configuration + +### Database Connection + +Your `default.props` should use `host.docker.internal` to connect to your local database: ```properties -db.url=jdbc:postgresql://host.docker.internal:5432/YOUR_DB_NAME?user=YOUR_DB_USER&password=YOUR_DB_PASSWORD -```` +db.driver=org.postgresql.Driver +db.url=jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=yourpassword +``` -> Use `host.docker.internal` so the container can reach your local database. +**Note**: The Docker setup automatically overrides the database URL via environment variable, so you can also configure it without modifying props files. ---- +### Redis Configuration + +Redis is configured automatically using OBP-API's environment variable override system: -### Build & run (production mode) +```yaml +# Automatically set by docker-compose.yml: +OBP_CACHE_REDIS_URL=redis # Connect to redis service +OBP_CACHE_REDIS_PORT=6379 # Internal Docker port +OBP_DB_URL=jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=f +``` -Build the Docker image and run the container: +### Custom Redis Port + +To customize configuration, edit `.env`: ```bash -docker-compose up --build +# .env file +OBP_CACHE_REDIS_PORT=6381 +OBP_DB_URL=jdbc:postgresql://host.docker.internal:5432/mydb?user=myuser&password=mypass ``` -The service will be available at [http://localhost:8080](http://localhost:8080). +Or set environment variables: ---- +```bash +export OBP_CACHE_REDIS_PORT=6381 +export OBP_DB_URL="jdbc:postgresql://host.docker.internal:5432/mydb?user=myuser&password=mypass" +docker-compose up --build +``` -## Development tips +## Container Names -For live code updates without rebuilding: +All containers use consistent `obp-api-*` naming: -* Use the provided `docker-compose.override.yml` which mounts only: +- `obp-api-app` - Main application +- `obp-api-redis` - Redis cache server +- `obp-api-network` - Docker network +- `obp-api-redis-data` - Redis data volume - ```yaml - volumes: - - ../obp-api:/app/obp-api - - ../obp-commons:/app/obp-commons - ``` -* This keeps other built files (like `entrypoint.sh`) intact. -* Avoid mounting the full `../:/app` because it overwrites the built image. +## Development Features ---- +### Props File Override -## Useful commands +The setup mounts your local props directory: +```yaml +volumes: + - ../../obp-api/src/main/resources/props:/app/props +``` -Rebuild the image and restart: +Environment variables take precedence over props files using OBP's built-in system: +- `cache.redis.url` β†’ `OBP_CACHE_REDIS_URL` +- `cache.redis.port` β†’ `OBP_CACHE_REDIS_PORT` +- `db.url` β†’ `OBP_DB_URL` -```bash -docker-compose up --build +### Live Development + +For code changes without rebuilds: +```yaml +# docker-compose.override.yml provides: +volumes: + - ../../obp-api:/app/obp-api + - ../../obp-commons:/app/obp-commons ``` -Stop the container: +## Useful Commands +### Service Management ```bash +# Start services +docker-compose up -d + +# View logs +docker-compose logs obp-api-app +docker-compose logs obp-api-redis + +# Stop services docker-compose down + +# Rebuild and restart +docker-compose up --build ``` ---- +### Redis Operations +```bash +# Connect to Redis CLI +docker exec -it obp-api-redis redis-cli -## Before first run +# Check Redis keys +docker exec obp-api-redis redis-cli KEYS "*" -Make sure your entrypoint script is executable: +# Monitor Redis commands +docker exec obp-api-redis redis-cli MONITOR +``` +### Container Inspection ```bash -chmod +x docker/entrypoint.sh +# List containers +docker-compose ps + +# Execute commands in containers +docker exec -it obp-api-app bash +docker exec -it obp-api-redis sh ``` ---- +## Troubleshooting -## Notes +### Redis Connection Issues +- Check if `OBP_CACHE_REDIS_URL=redis` is set correctly +- Verify Redis container is running: `docker-compose ps` +- Test Redis connection: `docker exec obp-api-redis redis-cli ping` -* The container uses `MAVEN_OPTS` to pass JVM `--add-opens` flags needed by Lift. -* In production, avoid volume mounts for better performance and consistency. +### Database Connection Issues +- Ensure local PostgreSQL is running +- Verify `host.docker.internal` resolves: `docker exec obp-api-app ping host.docker.internal` +- Check props file is mounted: `docker exec obp-api-app ls /app/props/` ---- +### Props Loading Issues +- Check external props are detected: `docker-compose logs obp-api-app | grep "external props"` +- Verify environment variables: `docker exec obp-api-app env | grep OBP_` -That’s it β€” now you can run: +## Environment Variables -```bash -docker-compose up --build +The setup uses OBP-API's built-in environment override system: + +| Props File Property | Environment Variable | Default | Description | +|---------------------|---------------------|---------|-------------| +| `cache.redis.url` | `OBP_CACHE_REDIS_URL` | `redis` | Redis hostname | +| `cache.redis.port` | `OBP_CACHE_REDIS_PORT` | `6379` | Redis port | +| `cache.redis.password` | `OBP_CACHE_REDIS_PASSWORD` | - | Redis password | +| `db.url` | `OBP_DB_URL` | `jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=f` | Database connection URL | + +## Network Architecture + +``` +Host Machine +β”œβ”€β”€ PostgreSQL :5432 +└── Docker Network (obp-api-network) + β”œβ”€β”€ obp-api-app :8080 β†’ :8080 + └── obp-api-redis :6379 β†’ :6380 ``` -and start coding! +- OBP-API connects to Redis via internal Docker network (`redis:6379`) +- OBP-API connects to PostgreSQL via `host.docker.internal:5432` +- Redis is accessible from host via `localhost:6380` + +## Notes + +- Container builds use multi-stage Dockerfile for optimized images +- Redis data persists in `obp-api-redis-data` volume +- Props files are mounted from host for easy development +- Environment variables override props file values automatically +- All containers restart automatically unless stopped manually + +--- -``` \ No newline at end of file +πŸš€ **Ready to develop!** Run `docker-compose up --build` and start coding. \ No newline at end of file diff --git a/development/docker/docker-compose.yml b/development/docker/docker-compose.yml index 6099f36269..7ea9c6f965 100644 --- a/development/docker/docker-compose.yml +++ b/development/docker/docker-compose.yml @@ -1,7 +1,19 @@ version: "3.8" services: + redis: + container_name: obp-api-redis + image: redis:7-alpine + ports: + - "${OBP_CACHE_REDIS_PORT:-6380}:6379" + command: redis-server --appendonly yes + volumes: + - redis_data:/data + networks: + - obp-network + obp-api: + container_name: obp-api-app build: context: ../.. dockerfile: development/docker/Dockerfile @@ -11,6 +23,14 @@ services: # Set Lift props location to find your props files - props.resource.dir=/app/props/ - JAVA_OPTS=-Drun.mode=production -Dprops.resource.dir=/app/props/ + # Override Redis settings via environment variables (OBP-API system) + # cache.redis.url -> OBP_CACHE_REDIS_URL + # cache.redis.port -> OBP_CACHE_REDIS_PORT + - OBP_CACHE_REDIS_URL=redis + - OBP_CACHE_REDIS_PORT=6379 + # Override database URL via environment variable (OBP-API system) + # db.url -> OBP_DB_URL + - OBP_DB_URL=${OBP_DB_URL:-jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=f} volumes: # Mount the props directory so the container uses your local props files - ../../obp-api/src/main/resources/props:/app/props @@ -19,3 +39,16 @@ services: # In your config file: # db.url=jdbc:postgresql://host.docker.internal:5432/YOUR_DB?user=YOUR_DB_USER&password=YOUR_DB_PASSWORD - "host.docker.internal:host-gateway" + depends_on: + - redis + networks: + - obp-network + +volumes: + redis_data: + name: obp-api-redis-data + +networks: + obp-network: + name: obp-api-network + driver: bridge From 93d7fcacd7d7976697bcb7eb6a8024dbf26f820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 27 Nov 2025 16:58:37 +0100 Subject: [PATCH 4/5] feature/Add openjdk version "17.0.11" at docker openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9) OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing) --- development/docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/docker/docker-compose.yml b/development/docker/docker-compose.yml index 7ea9c6f965..5b92c2c693 100644 --- a/development/docker/docker-compose.yml +++ b/development/docker/docker-compose.yml @@ -16,7 +16,7 @@ services: container_name: obp-api-app build: context: ../.. - dockerfile: development/docker/Dockerfile + dockerfile: development/docker/Dockerfile.dev ports: - "8080:8080" environment: From a999e351c8275bd10b7f294a96e998f74d3bdc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 27 Nov 2025 17:02:25 +0100 Subject: [PATCH 5/5] dockfix/Add openjdk version "17.0.11" at docker openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9) OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing) --- development/docker/README.md | 77 ++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/development/docker/README.md b/development/docker/README.md index 97d1897dcc..397678231c 100644 --- a/development/docker/README.md +++ b/development/docker/README.md @@ -1,14 +1,15 @@ # OBP-API Docker Development Setup -This Docker Compose setup provides a complete development environment for OBP-API with Redis caching support. +This Docker Compose setup provides a complete **live development environment** for OBP-API with Redis caching support and hot reloading capabilities. ## Services ### 🏦 **obp-api-app** -- Main OBP-API application -- Built with Maven 3 + OpenJDK 17 -- Runs on Jetty 9.4 +- Main OBP-API application with **live development mode** +- Built with Maven 3.9.6 + OpenJDK 17 +- Runs with Jetty Maven Plugin (`mvn jetty:run`) - Port: `8080` +- **Features**: Hot reloading, incremental compilation, live props changes ### πŸ”΄ **obp-api-redis** - Redis cache server @@ -38,14 +39,16 @@ This Docker Compose setup provides a complete development environment for OBP-AP ### Database Connection -Your `default.props` should use `host.docker.internal` to connect to your local database: +You can configure the database connection in multiple ways: +**Option 1: Props file** (traditional): ```properties db.driver=org.postgresql.Driver db.url=jdbc:postgresql://host.docker.internal:5432/obp_mapped?user=obp&password=yourpassword ``` -**Note**: The Docker setup automatically overrides the database URL via environment variable, so you can also configure it without modifying props files. +**Option 2: Environment variables** (recommended for Docker): +The setup automatically overrides database settings via environment variables, so you can configure without modifying props files. ### Redis Configuration @@ -100,14 +103,20 @@ Environment variables take precedence over props files using OBP's built-in syst - `cache.redis.port` β†’ `OBP_CACHE_REDIS_PORT` - `db.url` β†’ `OBP_DB_URL` -### Live Development +### Live Development Features -For code changes without rebuilds: +**πŸ”₯ Hot Reloading**: `Dockerfile.dev` uses `mvn jetty:run` for automatic recompilation and reloading: +- βœ… **Scala code changes** - Automatic recompilation and reload +- βœ… **Props file changes** - Live configuration updates via volume mount +- βœ… **Resource changes** - Instant refresh without container restart +- βœ… **Incremental builds** - Only changed files are recompiled + +**Volume Mounts for Development**: ```yaml -# docker-compose.override.yml provides: +# Automatically mounted by docker-compose: volumes: - - ../../obp-api:/app/obp-api - - ../../obp-commons:/app/obp-commons + - ../../obp-api/src/main/resources/props:/app/props # Live props updates + # Source code is copied during build for optimal performance ``` ## Useful Commands @@ -182,23 +191,51 @@ The setup uses OBP-API's built-in environment override system: ``` Host Machine β”œβ”€β”€ PostgreSQL :5432 +β”œβ”€β”€ Props Files (mounted) β†’ Docker Container └── Docker Network (obp-api-network) - β”œβ”€β”€ obp-api-app :8080 β†’ :8080 - └── obp-api-redis :6379 β†’ :6380 + β”œβ”€β”€ obp-api-app :8080 β†’ :8080 (Live Development Mode) + └── obp-api-redis :6379 β†’ :6380 (Persistent Cache) ``` -- OBP-API connects to Redis via internal Docker network (`redis:6379`) -- OBP-API connects to PostgreSQL via `host.docker.internal:5432` -- Redis is accessible from host via `localhost:6380` +**Connection Flow**: +- OBP-API ↔ Redis: Internal Docker network (`redis:6379`) +- OBP-API ↔ PostgreSQL: Host connection (`host.docker.internal:5432`) +- Props Files: Live mounted from host (`/app/props/`) +- Redis External: Accessible via `localhost:6380` + +## Development Benefits -## Notes +### ⚑ **Live Development Mode** (`Dockerfile.dev`) +- **Single-stage build** optimized for development speed +- **Hot reloading** with `mvn jetty:run` - code changes are reflected instantly +- **Incremental compilation** - only changed files are rebuilt +- **Live props updates** - configuration changes without container restart +- **Security compliant** - selective file copying (SonarQube approved) -- Container builds use multi-stage Dockerfile for optimized images +### πŸ”§ **Development vs Production** +- **Current setup**: Uses `Dockerfile.dev` for optimal development experience +- **Production ready**: Can switch to `Dockerfile` for multi-stage production builds +- **Best of both**: Live development with production-grade security practices + +### πŸ“‹ **Additional Notes** - Redis data persists in `obp-api-redis-data` volume -- Props files are mounted from host for easy development +- Props files are live-mounted from host for instant updates - Environment variables override props file values automatically +- Java 17 with proper module system compatibility - All containers restart automatically unless stopped manually --- -πŸš€ **Ready to develop!** Run `docker-compose up --build` and start coding. \ No newline at end of file +πŸš€ **Ready for live development!** + +```bash +cd development/docker +docker-compose up --build +# Start coding - changes are reflected automatically! πŸ”₯ +``` + +**Pro Tips**: +- Make code changes and see them instantly without rebuilding +- Update props files and they're loaded immediately +- Use `docker-compose logs obp-api -f` to watch live application logs +- Redis caching speeds up API responses significantly \ No newline at end of file