Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions core/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Gradle
.gradle/
build/
!gradle/wrapper/gradle-wrapper.jar
gradle-app.setting
!gradle-app.setting

# IDE
.idea/
.vscode/
*.iml
*.ipr
*.iws

# OS
.DS_Store
Thumbs.db

# Logs
logs/
*.log

# Runtime
target/
*.jar
!gradle/wrapper/gradle-wrapper.jar

# Test results
.allure/
build/reports/
build/test-results/

# Environment
.env
.env.local
.env.*.local

# Git
.git/
.gitignore

# Docker
Dockerfile
.dockerignore

# Documentation
README.md
docs/

# Temporary files
*.tmp
*.swp
*.bak
57 changes: 57 additions & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Multi-stage build for Spring Boot application
FROM openjdk:21-jdk-slim as builder

# Install curl, wget and unzip
RUN apt-get update && apt-get install -y curl wget unzip && \
wget -O /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.5-bin.zip && \
unzip /tmp/gradle.zip -d /opt && \
ln -s /opt/gradle-8.5/bin/gradle /usr/local/bin/gradle && \
rm /tmp/gradle.zip && \
rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy build files
COPY build.gradle .
COPY settings.gradle .

# Copy source code
COPY src/ src/

# Build the application
RUN gradle clean build -x test

# Runtime stage
FROM openjdk:21-slim

# Install curl for health checks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Create app user
RUN groupadd -r appuser && useradd -r -g appuser appuser

# Set working directory
WORKDIR /app

# Copy the built jar from builder stage
COPY --from=builder /app/build/libs/*.jar app.jar

# Create logs directory
RUN mkdir -p /app/logs && chown -R appuser:appuser /app

# Switch to app user
USER appuser

# Expose port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1

# JVM arguments for production
ENV JAVA_OPTS="-Xms512m -Xmx1g -XX:+UseG1GC -XX:+UseContainerSupport"

# Run the application
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
71 changes: 71 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.opencontext'
version = '1.0.0'

java {
sourceCompatibility = '21'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
// Spring Boot Starters
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'

// Database
runtimeOnly 'org.postgresql:postgresql'

// API Documentation
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

// Object Storage (MinIO)
implementation 'io.minio:minio:8.5.7'

// HTTP Client
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// Utilities
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.mapstruct:mapstruct:1.5.5.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'

// JSON Processing
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'

// Test Dependencies
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:postgresql'
testImplementation 'org.testcontainers:elasticsearch'
}

dependencyManagement {
imports {
mavenBom "org.testcontainers:testcontainers-bom:1.19.3"
}
}

tasks.named('test') {
useJUnitPlatform()
}
7 changes: 7 additions & 0 deletions core/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
161 changes: 161 additions & 0 deletions core/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'core'
16 changes: 16 additions & 0 deletions core/src/main/java/com/opencontext/OpenContextApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.opencontext;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@EnableJpaAuditing
@EnableAsync
public class OpenContextApplication {

public static void main(String[] args) {
SpringApplication.run(OpenContextApplication.class, args);
}
}
Loading