From 7b52109d1173276afcbae1855afa28531c0ee27e Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 29 Apr 2026 09:00:33 +0200 Subject: [PATCH] feat(devcontainer): add Docker and devcontainer configuration for NowChess workspace --- .devcontainer/Dockerfile | 9 +++ .devcontainer/README.md | 18 ++++++ .devcontainer/devcontainer.json | 39 ++++++++++++ .devcontainer/docker-compose.yml | 62 +++++++++++++++++++ jacoco-reporter/scoverage_coverage_gaps.py | 2 +- .../store/src/main/resources/application.yml | 19 ++++-- modules/ws/src/main/resources/application.yml | 6 -- 7 files changed, 142 insertions(+), 13 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..396402e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +FROM mcr.microsoft.com/devcontainers/java:21-bookworm + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + postgresql-client \ + redis-tools \ + stockfish \ + && rm -rf /var/lib/apt/lists/* + diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..60f7a5c --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,18 @@ +# Devcontainer + +Dieses Setup startet den NowChess-Workspace zusammen mit Redis und PostgreSQL. + +## Enthaltene Services +- `workspace` – Scala/Gradle-Entwicklungscontainer +- `redis` – Redis 7.4 +- `postgres` – PostgreSQL 16 + +## Wichtige Ports +- App-Services: `8080`, `8081`, `8082`, `8083`, `8084`, `8085`, `8086`, `9086` +- Redis auf dem Host: `16379` +- PostgreSQL auf dem Host: `15432` + +## Einstieg +- VS Code: Ordner in einem Dev Container öffnen +- IntelliJ: Dev Container / Docker-Compose-Workspace öffnen und den `workspace`-Dienst nutzen + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1de19ea --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +{ + "name": "NowChessSystems", + "dockerComposeFile": ["docker-compose.yml"], + "service": "workspace", + "workspaceFolder": "/workspaces/NowChessSystems", + "shutdownAction": "stopCompose", + "overrideCommand": false, + "remoteUser": "vscode", + "forwardPorts": [8080, 8081, 8082, 8083, 8084, 8085, 8086, 9086], + "portsAttributes": { + "8080": {"label": "NowChess Core", "onAutoForward": "notify"}, + "8081": {"label": "NowChess Io", "onAutoForward": "notify"}, + "8082": {"label": "NowChess Rule", "onAutoForward": "notify"}, + "8083": {"label": "NowChess Account", "onAutoForward": "notify"}, + "8084": {"label": "NowChess WebSocket", "onAutoForward": "notify"}, + "8085": {"label": "NowChess Store", "onAutoForward": "notify"}, + "8086": {"label": "NowChess Coordinator HTTP", "onAutoForward": "notify"}, + "9086": {"label": "NowChess Coordinator gRPC", "onAutoForward": "notify"} + }, + "customizations": { + "vscode": { + "settings": { + "java.configuration.updateBuildConfiguration": "automatic", + "java.import.gradle.wrapper.enabled": true, + "files.watcherExclude": { + "**/build/**": true, + "**/.gradle/**": true + } + }, + "extensions": [ + "scala-lang.scala", + "redhat.java", + "vscjava.vscode-java-pack" + ] + } + }, + "postCreateCommand": "bash -lc './gradlew --no-daemon help >/dev/null'" +} + diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..c512904 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,62 @@ +services: + workspace: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + command: sleep infinity + init: true + volumes: + - gradle-cache:/home/vscode/.gradle + environment: + REDIS_HOST: redis + REDIS_PORT: 6379 + REDIS_PREFIX: nowchess + DB_URL: jdbc:postgresql://postgres:5432/nowchess + DB_USER: nowchess + DB_PASSWORD: nowchess + CORE_SERVICE_URL: http://localhost:8080 + INTERNAL_SECRET: dev-internal-secret + STOCKFISH_PATH: /usr/games/stockfish + NOWCHESS_COORDINATOR_ENABLED: "true" + depends_on: + redis: + condition: service_healthy + postgres: + condition: service_healthy + + redis: + image: redis:7.4-alpine + command: ["redis-server", "--appendonly", "yes", "--save", "60", "1"] + ports: + - "16379:6379" + volumes: + - redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 5s + timeout: 3s + retries: 20 + start_period: 5s + + postgres: + image: postgres:16-alpine + environment: + POSTGRES_DB: nowchess + POSTGRES_USER: nowchess + POSTGRES_PASSWORD: nowchess + ports: + - "15432:5432" + volumes: + - postgres-data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] + interval: 5s + timeout: 3s + retries: 20 + start_period: 10s + +volumes: + gradle-cache: + redis-data: + postgres-data: + diff --git a/jacoco-reporter/scoverage_coverage_gaps.py b/jacoco-reporter/scoverage_coverage_gaps.py index 587d812..055094f 100644 --- a/jacoco-reporter/scoverage_coverage_gaps.py +++ b/jacoco-reporter/scoverage_coverage_gaps.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python3.set """ scoverage Coverage Gap Reporter Parses a scoverage XML report (scoverage.xml) and outputs missing statement diff --git a/modules/store/src/main/resources/application.yml b/modules/store/src/main/resources/application.yml index a62b788..badc025 100644 --- a/modules/store/src/main/resources/application.yml +++ b/modules/store/src/main/resources/application.yml @@ -1,16 +1,21 @@ quarkus: - application.name: nowchess-store + application: + name: nowchess-store http.port: 8085 - config.yaml.enabled: true + config: + yaml: + enabled: true redis: hosts: redis://${REDIS_HOST:localhost}:${REDIS_PORT:6379} datasource: db-kind: postgresql username: ${DB_USER:nowchess} password: ${DB_PASSWORD:nowchess} - jdbc.url: ${DB_URL:jdbc:postgresql://localhost:5432/nowchess} + jdbc: + url: ${DB_URL:jdbc:postgresql://localhost:5432/nowchess} hibernate-orm: - database.generation: update + database: + generation: update nowchess: redis: @@ -24,9 +29,11 @@ nowchess: db-kind: h2 username: sa password: "" - jdbc.url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + jdbc: + url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE hibernate-orm: - database.generation: drop-and-create + database: + generation: drop-and-create nowchess: redis: host: localhost diff --git a/modules/ws/src/main/resources/application.yml b/modules/ws/src/main/resources/application.yml index 15f707a..ac82f36 100644 --- a/modules/ws/src/main/resources/application.yml +++ b/modules/ws/src/main/resources/application.yml @@ -5,12 +5,6 @@ quarkus: name: nowchess-ws redis: hosts: redis://${REDIS_HOST:localhost}:${REDIS_PORT:6379} - swagger-ui: - always-include: true - path: /swagger-ui - grpc: - server: - use-separate-server: false nowchess: redis: