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
58 changes: 58 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Qodana Code Quality

on:
workflow_dispatch:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]

jobs:
qodana:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
pull-requests: write
checks: write
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Qodana Scan
uses: JetBrains/qodana-action@v2024.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
pr-mode: ${{ github.event_name == 'pull_request' }}
use-caches: true
post-pr-comment: true
use-annotations: true
upload-result: true
push-fixes: 'none'
fail-threshold: 0

- name: Upload SARIF file
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
category: qodana
4 changes: 3 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
contents: read
security-events: write
issues: write
pull-requests: write

strategy:
fail-fast: false
Expand Down Expand Up @@ -60,8 +61,9 @@ jobs:

- name: Notify on failure
if: failure() && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = context.payload.pull_request
? context.payload.pull_request.number
Expand Down
35 changes: 14 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
# Use a base image with Java 21 installed
# Build stage
FROM openjdk:21-jdk-slim AS build

# Set the working directory inside the container
WORKDIR /app

# Copy the Maven wrapper and the project definition file
COPY .mvn/ .mvn
COPY mvnw pom.xml ./

# Make the Maven wrapper executable
RUN chmod +x mvnw

# Download dependencies. This layer is cached if pom.xml doesn't change.
RUN ./mvnw dependency:go-offline

# Copy the rest of your application's source code
COPY src ./src

# Package the application into a JAR file
RUN ./mvnw package -DskipTests && ls -la /app/target/

# Use a smaller base image for the final application
# Runtime stage
FROM openjdk:21-jdk-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the Maven wrapper and the project definition file from the build stage
# Install Tesseract OCR and language data
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr tesseract-ocr-eng \
&& rm -rf /var/lib/apt/lists/*

# Copy app
COPY --from=build /app/target/*.jar UnravelDocs.jar

# Expose the port your application runs on
EXPOSE 8080
# Tesseract data path
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata
# Keep JVM memory within dyno limits
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -XX:+UseSerialGC"

# Command to run the application
ENTRYPOINT ["java", "-jar", "UnravelDocs.jar"]
# Heroku provides PORT; bind server to it
CMD sh -c 'java $JAVA_OPTS -Dserver.port=${PORT:-8080} -Dspring.profiles.active=heroku -jar UnravelDocs.jar'
132 changes: 113 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,120 @@
version: '3.8'

services:
localstack:
image: localstack/localstack:4.4.0
unraveldocs-api:
build: .
container_name: unraveldocs-api
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
localstack:
condition: service_healthy
environment:
# Database
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/unraveldocs
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
# Redis
- SPRING_DATA_REDIS_URL=redis://redis:6379
# RabbitMQ
- SPRING_RABBITMQ_HOST=rabbitmq
- SPRING_RABBITMQ_PORT=5672
- SPRING_RABBITMQ_USERNAME=guest
- SPRING_RABBITMQ_PASSWORD=guest
# AWS S3
- SPRING_CLOUD_AWS_S3_ENDPOINT=http://localstack:4566
- SPRING_CLOUD_AWS_S3_PATH_STYLE_ACCESS_ENABLED=true
- SPRING_CLOUD_AWS_CREDENTIALS_ACCESS-KEY=test
- SPRING_CLOUD_AWS_CREDENTIALS_SECRET-KEY=test
- SPRING_CLOUD_AWS_REGION_STATIC=eu-north-1
networks:
- unraveldocs-net

postgres:
image: postgres:17
container_name: postgres
ports:
- "4566:4566"
- "5432:5432"
environment:
- SERVICES=s3
- GATEWAY_LISTEN=0.0.0.0:4566
- LOCALSTACK_HOST=localstack
- DOCKER_HOST=unix:///var/run/docker.sock
- DEBUG=1
- MAIN_CONTAINER_NAME=localstack
- PERSISTENCE=0
- LS_LOG=trace
- SKIP_SSL_CERT_DOWNLOAD=1
- START_WEB=0
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: unraveldocs
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "curl", "-s", "http://localhost:4566/_localstack/health", "|", "grep", "'\"s3\": \"running\"'"]
interval: 15s
timeout: 15s
retries: 20
test: ["CMD-SHELL", "pg_isready -U postgres -d unraveldocs"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unraveldocs-net

redis:
image: redis:7-alpine
container_name: redis
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unraveldocs-net

rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unraveldocs-net

localstack:
image: localstack/localstack
container_name: localstack
ports:
- "4566:4566" # LocalStack Gateway
- "4510-4559:4510-4559" # LocalStack services
environment:
- SERVICES=s3,sqs,lambda,cloudformation
- DEFAULT_REGION=eu-north-1
- AWS_ACCESS_KEY_ID=test
- AWS_SECRET_ACCESS_KEY=test
volumes:
- localstack_data:/var/lib/localstack
- /var/run/docker.sock:/var/run/docker.sock
mem_limit: 4g
cpus: '2'
healthcheck:
test: ["CMD", "awslocal", "s3", "ls"]
interval: 10s
timeout: 5s
retries: 5
networks:
- unraveldocs-net

# Volumes for persistent data
volumes:
postgres_data:
driver: local
localstack_data:
driver: local

# Network for inter-service communication
networks:
unraveldocs-net:
driver: bridge
Loading
Loading