Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c356cf5
feat(worker): add docker-compose configuration for postgres and redis
nakberli841-bot Jun 11, 2026
2897313
feat(backend): add postgres and redis configs to api and worker
nakberli841-bot Jun 11, 2026
a02ca4b
docs(backend): add docker setup instructions to README
nakberli841-bot Jun 11, 2026
fd4836d
test(infra): configure Testcontainers with ServiceConnection for api …
nakberli841-bot Jun 11, 2026
430e129
chore(backend): use testcontainers-bom for version management
nakberli841-bot Jun 13, 2026
96e7b69
chore(backend): Enable health checks for database and redis in both a…
nakberli841-bot Jun 13, 2026
4b4268d
chore(docker): improve postgres setup with volumes and healthchecks
nakberli841-bot Jun 13, 2026
164131c
chore(backend): configure environment variables and dynamic database …
nakberli841-bot Jun 13, 2026
e436601
docs(backend): update readme with clear instructions for docker and g…
nakberli841-bot Jun 13, 2026
aec5807
fix(deps): add spring-boot-testcontainers dependency for integration …
nakberli841-bot Jun 13, 2026
462dbf5
Merge branch 'main' into feature/4-docker-compose-setup
nakberli841-bot Jun 19, 2026
0f41b8f
Update application.yml
nakberli841-bot Jun 19, 2026
4250c55
Delete backend/docker
nakberli841-bot Jun 19, 2026
4b0c3b1
refactor: clean up files, README, and health configuration
nakberli841-bot Jun 19, 2026
e06d034
docs: update README (missed in previous commit)
nakberli841-bot Jun 19, 2026
0727719
Delete backend/initializationError,backend/Task,backend/There
nakberli841-bot Jun 19, 2026
2954736
Create .env.example
nakberli841-bot Jun 19, 2026
18f4833
Delete backend/There,backed/Task
nakberli841-bot Jun 20, 2026
0c3ebfd
Delete backend/Task
nakberli841-bot Jun 20, 2026
6289031
Delete .env.example
nakberli841-bot Jun 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
POSTGRES_USER=cleat
POSTGRES_PASSWORD=password
POSTGRES_DB=cleat_db

DB_USERNAME=cleat
DB_PASSWORD=password
DB_NAME=cleat_db
DB_HOST=localhost
REDIS_HOST=localhost
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build/
# Local env
*.local
application-local.yml
.env

33 changes: 31 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,34 @@ for example `dev.cleat.domain` and `dev.cleat.githubclient`.
./gradlew build # build and test everything
```

Local dependencies (Postgres, Redis) are expected to run via Docker Compose. The
two services build into one container image each.
Local dependencies (Postgres, Redis) are expected to run via Docker Compose, while the API and Worker services are intended to be run locally via Gradle


# Docker Setup

This project uses Docker Compose to orchestrate infrastructure services (PostgreSQL and Redis), while the API and Worker modules are managed via Gradle.

## Prerequisites

* Docker
* Docker Compose

## Getting Started

Navigate to the `backend` directory and use the following commands:

### 1. Infrastructure (Docker)
Start the PostgreSQL and Redis containers:
`docker compose up -d`

### 2. Running the Application (Gradle)
Use Gradle to run the modules:

* For the API module: `./gradlew :apps:api:bootRun`
* For the Worker module: `./gradlew :apps:worker:bootRun`

> **Note:** Running integration tests locally requires the Docker containers to be up and running.

## Configuration

Environment-specific configurations are managed within the `application.yml` files located in each module (api and worker).
4 changes: 4 additions & 0 deletions backend/apps/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-security")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
testImplementation("org.testcontainers:testcontainers")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
}
25 changes: 16 additions & 9 deletions backend/apps/api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
spring:
application:
name: cleat-api
autoconfigure:
exclude:
# Temporary: database is not wired yet.
# Remove these excludes once datasource is configured in issue #5.
- org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
- org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration
datasource:
url: jdbc:postgresql://${DB_HOST:localhost}:5432/${DB_NAME:cleat_db}
username: ${DB_USERNAME:cleat}
password: ${DB_PASSWORD:password}
driver-class-name: org.postgresql.Driver

data:
redis:
host: ${REDIS_HOST:localhost}
port: 6379

server:
port: 8080
Expand All @@ -17,8 +20,12 @@ management:
web:
exposure:
include: health,info
endpoint:
health:
probes:
enabled: true
health:
defaults:
db:
enabled: true
redis:
enabled: false
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.cleat.api;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
@SpringBootTest
public abstract class AbstractIntegrationTest {

@Container
@ServiceConnection
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine");

@Container
@ServiceConnection
static GenericContainer<?> redis = new GenericContainer<>("redis:7-alpine").withExposedPorts(6379);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class CleatApiTests {
public class CleatApiTests extends AbstractIntegrationTest {

@Test
void contextLoad() {}
Expand Down
4 changes: 4 additions & 0 deletions backend/apps/worker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
testImplementation("org.testcontainers:testcontainers")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
}
22 changes: 16 additions & 6 deletions backend/apps/worker/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
spring:
application:
name: cleat-worker
# TODO: These excludes are temporary until the datasource lands in #5
autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
- org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
datasource:
url: jdbc:postgresql://${DB_HOST:localhost}:5432/${DB_NAME:cleat_db}
username: ${DB_USERNAME:cleat}
password: ${DB_PASSWORD:password}
driver-class-name: org.postgresql.Driver

data:
redis:
host: ${REDIS_HOST:localhost}
port: 6379

server:
port: 8081
Expand All @@ -18,4 +23,9 @@ management:
endpoint:
health:
probes:
enabled: true
enabled: true
Comment thread
nakberli841-bot marked this conversation as resolved.
health:
db:
enabled: true
redis:
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.cleat.worker;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
@SpringBootTest
public abstract class AbstractIntegrationTest {

@Container
@ServiceConnection
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine");

@Container
@ServiceConnection
static GenericContainer<?> redis = new GenericContainer<>("redis:7-alpine").withExposedPorts(6379);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class CleatWorkerApplicationTests {
public class CleatWorkerApplicationTests extends AbstractIntegrationTest {

@Test
void contextLoads() {}
Expand Down
1 change: 1 addition & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ subprojects {
the<io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension>().apply {
imports {
mavenBom(SpringBootPlugin.BOM_COORDINATES)
mavenBom("org.testcontainers:testcontainers-bom:1.20.1")
}
}

Expand Down
24 changes: 24 additions & 0 deletions backend/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-cleat}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: ${POSTGRES_DB:-cleat_db}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-cleat}"]
interval: 5s
timeout: 5s
retries: 5

redis:
image: redis:7
ports:
- "6379:6379"

volumes:
postgres_data:
Loading