Skip to content

Commit 1d62372

Browse files
CopilotFabiPunktExe
andcommitted
Final refactoring: extract Docker tasks, improve organization and add documentation
Co-authored-by: FabiPunktExe <66797305+FabiPunktExe@users.noreply.github.com>
1 parent bce46dd commit 1d62372

File tree

4 files changed

+117
-52
lines changed

4 files changed

+117
-52
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Vertically Spinning Fish
2+
3+
A container management application built with Java.
4+
5+
## Project Structure
6+
7+
This project is organized as a multi-module Gradle build:
8+
9+
### Modules
10+
11+
- **`common/`** - Shared data models and API interfaces
12+
- **`api/`** - Client library for external consumers
13+
- **`velocity-plugin/`** - Velocity server plugin
14+
- **Root module** - Main application and server
15+
16+
### Build Configuration
17+
18+
- **`buildSrc/`** - Gradle convention plugins for shared build logic
19+
- **`gradle/libs.versions.toml`** - Centralized dependency version management
20+
- **`gradle/docker.gradle.kts`** - Docker-related build tasks
21+
22+
## Building
23+
24+
```bash
25+
./gradlew build
26+
```
27+
28+
## Running
29+
30+
```bash
31+
./gradlew run
32+
```
33+
34+
This will start the application in a Docker container.
35+
36+
## Project Layout
37+
38+
```
39+
├── api/ # Client API library
40+
├── common/ # Shared models and interfaces
41+
├── velocity-plugin/ # Velocity plugin
42+
├── src/ # Main application sources
43+
├── buildSrc/ # Build convention plugins
44+
├── gradle/ # Gradle configuration
45+
└── build.gradle.kts # Root build configuration
46+
```
47+
48+
## Development
49+
50+
The project uses Java 21 and follows modern Gradle conventions with:
51+
52+
- Version catalogs for dependency management
53+
- Convention plugins for shared build logic
54+
- Clear module separation and dependencies
55+
- Docker integration for deployment

build.gradle.kts

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ dependencies {
1010
implementation(libs.okhttp)
1111
implementation(libs.slf4j.simple)
1212
implementation(libs.bundles.javalin)
13+
implementation(libs.commons.io)
14+
implementation(libs.guava)
1315
annotationProcessor(libs.javalin.annotation.processor)
1416
runtimeOnly(libs.activation)
1517
}
@@ -44,59 +46,11 @@ tasks {
4446
}
4547
archiveFileName = "VerticallySpinningFish.jar"
4648
}
47-
48-
register<Exec>("run") {
49-
dependsOn(jar)
50-
commandLine = listOf(
51-
"docker", "run",
52-
"--rm",
53-
"--volume", "${projectDir}/run:/data",
54-
"--volume", "${jar.get().outputs.files.asPath}:/root/VerticallySpinningFish.jar",
55-
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
56-
"--publish", "7000:7000",
57-
"--workdir", "/data",
58-
"--interactive",
59-
"openjdk:25",
60-
"java", "-jar", "/root/VerticallySpinningFish.jar")
61-
standardOutput = System.out
62-
errorOutput = System.err
63-
standardInput = System.`in`
64-
}
65-
66-
register("publishDockerImage") {
67-
dependsOn(jar)
68-
group = "Publishing"
69-
doFirst {
70-
ProcessBuilder(
71-
"docker", "build",
72-
"--tag", "docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}",
73-
".")
74-
.inheritIO().start().waitFor()
75-
ProcessBuilder(
76-
"docker", "tag",
77-
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}",
78-
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:latest")
79-
.inheritIO().start().waitFor()
80-
val username = (System.getenv("DIRUPTIO_REPO_USERNAME") ?: project.findProperty("docker_username") ?: "").toString()
81-
val password = (System.getenv("DIRUPTIO_REPO_PASSWORD") ?: project.findProperty("docker_password") ?: "").toString()
82-
ProcessBuilder(
83-
"docker", "login",
84-
"--username", username,
85-
"--password", password,
86-
"docker-public.diruptio.de")
87-
.inheritIO().start().waitFor()
88-
ProcessBuilder(
89-
"docker", "push",
90-
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}")
91-
.inheritIO().start().waitFor()
92-
ProcessBuilder(
93-
"docker", "push",
94-
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:latest")
95-
.inheritIO().start().waitFor()
96-
}
97-
}
9849
}
9950

51+
// Apply Docker-related tasks
52+
apply(from = "gradle/docker.gradle.kts")
53+
10054
subprojects {
10155
group = rootProject.group
10256
version = rootProject.version

gradle/docker.gradle.kts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
tasks {
2+
register<Exec>("run") {
3+
group = "Application"
4+
description = "Run the application in Docker"
5+
dependsOn(jar)
6+
commandLine = listOf(
7+
"docker", "run",
8+
"--rm",
9+
"--volume", "${projectDir}/run:/data",
10+
"--volume", "${jar.get().outputs.files.asPath}:/root/VerticallySpinningFish.jar",
11+
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
12+
"--publish", "7000:7000",
13+
"--workdir", "/data",
14+
"--interactive",
15+
"openjdk:25",
16+
"java", "-jar", "/root/VerticallySpinningFish.jar")
17+
standardOutput = System.out
18+
errorOutput = System.err
19+
standardInput = System.`in`
20+
}
21+
22+
register("publishDockerImage") {
23+
group = "Publishing"
24+
description = "Build and publish Docker image"
25+
dependsOn(jar)
26+
doFirst {
27+
ProcessBuilder(
28+
"docker", "build",
29+
"--tag", "docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}",
30+
".")
31+
.inheritIO().start().waitFor()
32+
ProcessBuilder(
33+
"docker", "tag",
34+
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}",
35+
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:latest")
36+
.inheritIO().start().waitFor()
37+
val username = (System.getenv("DIRUPTIO_REPO_USERNAME") ?: project.findProperty("docker_username") ?: "").toString()
38+
val password = (System.getenv("DIRUPTIO_REPO_PASSWORD") ?: project.findProperty("docker_password") ?: "").toString()
39+
ProcessBuilder(
40+
"docker", "login",
41+
"--username", username,
42+
"--password", password,
43+
"docker-public.diruptio.de")
44+
.inheritIO().start().waitFor()
45+
ProcessBuilder(
46+
"docker", "push",
47+
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:${version}")
48+
.inheritIO().start().waitFor()
49+
ProcessBuilder(
50+
"docker", "push",
51+
"docker-public.diruptio.de/diruptio/vertically-spinning-fish:latest")
52+
.inheritIO().start().waitFor()
53+
}
54+
}
55+
}

src/main/java/diruptio/verticallyspinningfish/VerticallySpinningFish.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import com.github.dockerjava.core.DockerClientConfig;
88
import com.google.common.hash.Hashing;
99
import diruptio.util.config.Config;
10-
import diruptio.verticallyspinningfish.api.*;
10+
import diruptio.verticallyspinningfish.api.ApiBridge;
1111
import diruptio.verticallyspinningfish.api.Container;
12+
import diruptio.verticallyspinningfish.api.Status;
1213
import diruptio.verticallyspinningfish.api.endpoints.LiveUpdatesWebSocket;
1314
import diruptio.verticallyspinningfish.template.CopyStep;
1415
import diruptio.verticallyspinningfish.template.TemplateBuilder;

0 commit comments

Comments
 (0)