From a34bd9971e6701e596a1959fab2cc17c9b26b35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20Angerg=C3=A5rd?= Date: Mon, 26 Aug 2024 21:33:45 +0200 Subject: [PATCH] Devcontainer --- .devcontainer/devcontainer.json | 26 ++++++++++++++++++++ .devcontainer/docker-compose.yml | 33 ++++++++++++++++++++++++++ app/build.gradle | 4 ---- app/compose.yml | 24 ------------------- app/src/main/resources/application.yml | 17 ++++--------- no_backend.docker-compose.yml | 21 ---------------- 6 files changed, 63 insertions(+), 62 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml delete mode 100644 app/compose.yml delete mode 100644 no_backend.docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..58d1c115b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +{ + "name": "Gamma Devcontainer", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + "features": { + "ghcr.io/devcontainers/features/java:1": { + "installGradle": true, + "gradleVersion": "8.10", + "jdkDistro": "open" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "20" + } + }, + + "forwardPorts": [8081], + + "customizations" : { + "jetbrains" : { + "backend" : "IntelliJ" + } + } + +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..9f57116e2 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,33 @@ +volumes: + postgres-data: + +services: + app: + container_name: javadev + image: mcr.microsoft.com/devcontainers/java:1-21 + volumes: + - ../..:/workspaces:cached + command: sleep infinity + + db: + image: postgres:16 + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + ports: + - "5432:5432" + + redis: + image: redis:5.0 + restart: always + ports: + - "6379:6379" + + gotify: + image: cthit/gotify:latest + environment: + GOTIFY_PRE-SHARED-KEY: "123abc" + GOTIFY_MOCK-MODE: "true" + GOTIFY_DEBUG-MODE: "true" + ports: + - "80:80" \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 1168967bd..d04d27d4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,10 +72,6 @@ dependencies { "org.webjars.npm:hyperscript.org:0.9.12", "org.webjars.npm:picocss__pico:2.0.6" ) - - developmentOnly( - "org.springframework.boot:spring-boot-docker-compose:3.3.0" - ) } repositories { diff --git a/app/compose.yml b/app/compose.yml deleted file mode 100644 index 074550eca..000000000 --- a/app/compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: "3" -services: - db: - image: postgres:16 - environment: - POSTGRES_DB: db - POSTGRES_USER: postgres - POSTGRES_PASSWORD: example - ports: - - '5432:5432' - - redis: - image: redis:5.0 - ports: - - '6379:6379' - - gotify: - image: cthit/gotify - environment: - GOTIFY_PRE-SHARED-KEY: "123abc" - GOTIFY_MOCK-MODE: "true" - GOTIFY_DEBUG-MODE: "true" - ports: - - '8080:8080' \ No newline at end of file diff --git a/app/src/main/resources/application.yml b/app/src/main/resources/application.yml index 4e22d79ca..c0b8719d0 100644 --- a/app/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -1,18 +1,9 @@ --- spring: - docker: - compose: - lifecycle-management: "start-and-stop" - start: - command: "UP" - stop: - command: "down" - readiness: - timeout: 10m datasource: username: "${DB_USER:postgres}" - password: "${DB_PASSWORD:example}" - url: "jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:postgres}" + password: "${DB_PASSWORD:postgres}" + url: "jdbc:postgresql://${DB_HOST:db}:${DB_PORT:5432}/${DB_NAME:postgres}" flyway: baseline-on-migrate: true locations: "classpath:/db/migration" @@ -34,7 +25,7 @@ spring: max-file-size: 50MB data: redis: - host: "${REDIS_HOST:0.0.0.0}" + host: "${REDIS_HOST:redis}" password: "${REDIS_PASSWORD:}" port: "${REDIS_PORT:6379}" repositories: @@ -75,4 +66,4 @@ application: admin-setup: "${ADMIN_SETUP:true}" gotify: key: "${GOTIFY_KEY:123abc}" - url: "${GOTIFY_BASE_URL:http://localhost:8080}" + url: "${GOTIFY_BASE_URL:http://db:8080}" diff --git a/no_backend.docker-compose.yml b/no_backend.docker-compose.yml deleted file mode 100644 index 1e7669471..000000000 --- a/no_backend.docker-compose.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3" -services: - db: - image: postgres:16 - restart: always - environment: - POSTGRES_PASSWORD: example - network_mode: host - - redis: - image: redis:5.0 - restart: always - network_mode: host - - gotify: - image: cthit/gotify - environment: - GOTIFY_PRE-SHARED-KEY: "123abc" - GOTIFY_MOCK-MODE: "true" - GOTIFY_DEBUG-MODE: "true" - network_mode: host