Skip to content

Commit 76185cf

Browse files
committed
Migrated docker.. to camundala.
1 parent d541363 commit 76185cf

File tree

6 files changed

+128
-11
lines changed

6 files changed

+128
-11
lines changed

00-documentation/src/docs/development/projectDev.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The `version` is optional and defaults to `1`.
1515
Whenever you have changes in the `company-camundala` project or in one of your dependencies,
1616
you can update the project with the following command:
1717

18+
Usage / example:
1819
```bash
1920
./helper.scala update
2021
```
@@ -29,6 +30,11 @@ You will get a warning, but the file will not be replaced.
2930

3031
Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)
3132

33+
@:callout(info)
34+
Adjust the `CompanyDevHelper.publishConfig` configuration.
35+
36+
@:@
37+
3238
Usage:
3339
```
3440
./helper.scala publish <VERSION>
@@ -252,3 +258,39 @@ This creates the following files:
252258
02-bpmn - main -> mycompany.myproject.bpmn.myProcess.v1.MyTimerEvent
253259
```
254260

261+
## Docker
262+
To run the Camunda Server locally, you can use `docker-compose`.
263+
264+
@:callout(info)
265+
**Precondition**:
266+
- You have to have `docker` and `docker-compose` installed.
267+
- You need to have a `docker-compose.yml` in `dev-company/docker` directory.
268+
- Adjust the `CompanyDevHelper.dockerConfig` configuration.
269+
270+
@:@
271+
272+
### dockerUp
273+
Starts the server with `docker-compose`.
274+
275+
Usage / example:
276+
```
277+
./helper.scala dockerUp
278+
```
279+
280+
### dockerStop
281+
Stops the server with `docker-compose`.
282+
283+
Usage / example:
284+
```
285+
./helper.scala dockerStop
286+
```
287+
288+
### dockerDown
289+
Stops and removes the server with `docker-compose`.
290+
291+
**Be aware** that all data will be lost - you have to deploy again.
292+
293+
Usage / example:
294+
```
295+
./helper.scala dockerDown
296+
```

04-helper/src/main/scala/camundala/helper/dev/DevHelper.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package camundala.helper.dev
22

33
import camundala.api.ApiConfig
44
import camundala.helper.dev.deploy.DeployHelper
5+
import camundala.helper.dev.docker.DockerHelper
56
import camundala.helper.dev.publish.PublishHelper
6-
import camundala.helper.util.{DeployConfig, DevConfig, PublishConfig}
7+
import camundala.helper.util.*
78
import camundala.helper.dev.update.*
89

910
import scala.util.{Failure, Success, Try}
@@ -13,6 +14,7 @@ trait DevHelper:
1314
def devConfig: DevConfig
1415
def publishConfig: Option[PublishConfig]
1516
def deployConfig: Option[DeployConfig]
17+
def dockerConfig: DockerConfig
1618
given DevConfig = devConfig
1719
given ApiConfig = apiConfig
1820
given Option[PublishConfig] = publishConfig
@@ -119,18 +121,15 @@ trait DevHelper:
119121
case other =>
120122
println(s"Invalid arguments for command $command: $other")
121123
println(s"Usage: $command <simulation>")
122-
println(s"Example: $command OpenAccountSimulation") /*
124+
println(s"Example: $command OpenAccountSimulation")
125+
// docker
123126
case Command.dockerUp =>
124-
args match
125-
case Seq(imageVersion) =>
126-
DockerHelper().dockerUp(Some(imageVersion))
127-
case _ =>
128-
DockerHelper().dockerUp(None)
127+
DockerHelper(dockerConfig).dockerUp()
129128
case Command.dockerStop =>
130-
DockerHelper().dockerStop()
129+
DockerHelper(dockerConfig).dockerStop()
131130
case Command.dockerDown =>
132-
DockerHelper().dockerDown()
133-
*/
131+
DockerHelper(dockerConfig).dockerDown()
132+
134133
private def printBadActivity(command: Command, args: Seq[String]): Unit =
135134
println(s"Invalid arguments for command $command: $args")
136135
println(s"Usage: $command <processName> <bpmnName> [version: Int]")

04-helper/src/main/scala/camundala/helper/dev/company/CompanyWrapperGenerator.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
148148
|
149149
| lazy val publishConfig: Option[PublishConfig] = None //TODO If you have a webdav server to publish the docs, add the config here
150150
| lazy val deployConfig: Option[DeployConfig] = None //TODO If you have a Postman account, add the config here
151+
| lazy val dockerConfig: DockerConfig = DockerConfig() //TODO Adjust the DockerConfig if needed
151152
|""".stripMargin
152153
end helperWrapper
153154

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package camundala.helper.dev.docker
2+
3+
import camundala.helper.util.{DockerConfig, Helpers}
4+
5+
case class DockerHelper(dockerConfig: DockerConfig) extends Helpers:
6+
7+
val dockerDir = dockerConfig.dockerDir
8+
9+
def dockerUp(): Unit =
10+
dockerConfig.prepareDocker()
11+
12+
println(s"Docker Images are starting - see the Docker Logs.")
13+
runDocker("up")
14+
dockerConfig.checkPorts.foreach:
15+
case label -> port =>
16+
check(label, port)
17+
18+
println(s"Docker Images started successfully.")
19+
dockerConfig.printResults.foreach:
20+
println
21+
22+
end dockerUp
23+
24+
def dockerStop(): Unit =
25+
print("Stop")
26+
println(s"Docker Images are stopping - see the Docker Logs.")
27+
runDocker("stop")
28+
end dockerStop
29+
30+
def dockerDown(): Unit =
31+
print("Down")
32+
println(
33+
s"Docker Images are stopping and will be removed - see the Docker Logs."
34+
)
35+
runDocker("down")
36+
end dockerDown
37+
38+
private def print(
39+
command: String
40+
): Unit =
41+
println(s"""$command Docker-Compose:
42+
|- Docker Directory: $dockerDir""".stripMargin)
43+
end print
44+
45+
private def runDocker(command: String) =
46+
os.proc(
47+
"docker-compose",
48+
dockerConfig.dockerComposePaths
49+
.flatMap: p =>
50+
Seq("-f", (dockerDir / p).toString),
51+
"--project-directory",
52+
s"$dockerDir",
53+
"-p",
54+
s"helper-docker",
55+
command,
56+
command match
57+
case "up" => "-d"
58+
case "stop" => Seq("--timeout", "15") // the only valid param
59+
case "down" =>
60+
Seq(
61+
"--volumes",
62+
"--remove-orphans"
63+
) // Remove containers for services not defined in the Compose file
64+
).callOnConsole()
65+
end DockerHelper
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package camundala.helper.util
2+
3+
case class DockerConfig(
4+
prepareDocker: () => Unit = () => (),
5+
// relative from the project root
6+
dockerDir: os.RelPath = os.rel / os.up / os.up / "docker",
7+
// relative from the dockerDir
8+
dockerComposePaths: Seq[os.RelPath] = Seq(os.rel / "docker-compose.yml"),
9+
checkPorts: Seq[(String, Int)] = Seq("Camunda" -> 8080),
10+
printResults: Seq[String] = Seq("Check Camunda on http://localhost:8080")
11+
)

04-helper/src/main/scala/camundala/helper/util/Helpers.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ trait Helpers:
1010
println(s"Working Directory: $wd")
1111
wd
1212
end workDir
13-
protected val dockerDir: os.Path = workDir / os.up / os.up / "docker"
1413

1514
protected def check(label: String, port: Int): Unit =
1615
var checking = true

0 commit comments

Comments
 (0)