mirror of
https://github.com/DerDavidBohl/dirigent-spring.git
synced 2026-05-20 19:39:11 -05:00
Small improvements for volume and command handling
This commit is contained in:
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -77,7 +78,12 @@ public class DeploymentsService {
|
||||
try {
|
||||
gitService.cloneOrPull(deployment.source(), deploymentDir.getAbsolutePath());
|
||||
|
||||
new ProcessBuilder(composeCommand, "up", "-d", "--remove-orphans")
|
||||
List<String> commandArgs = new java.util.ArrayList<>(Arrays.stream(composeCommand.split(" ")).toList());
|
||||
commandArgs.add("up");
|
||||
commandArgs.add("-d");
|
||||
commandArgs.add("--remove-orphans");
|
||||
|
||||
new ProcessBuilder(commandArgs)
|
||||
.directory(deploymentDir)
|
||||
.start().waitFor();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@@ -24,7 +25,7 @@ public class GitService {
|
||||
|
||||
File destinationDir = new File(destination);
|
||||
|
||||
if (destinationDir.exists()) {
|
||||
if (destinationDir.exists() && Arrays.asList(Objects.requireNonNull(destinationDir.list())).contains(".git")) {
|
||||
logger.debug("Local Repo exists. Pulling latest changes.");
|
||||
new ProcessBuilder("git", "fetch", "--all")
|
||||
.directory(destinationDir).start().waitFor();
|
||||
@@ -47,14 +48,14 @@ public class GitService {
|
||||
}
|
||||
}
|
||||
|
||||
boolean deleteDirectory(File directoryToBeDeleted) {
|
||||
void deleteDirectory(File directoryToBeDeleted) {
|
||||
File[] allContents = directoryToBeDeleted.listFiles();
|
||||
if (allContents != null) {
|
||||
for (File file : allContents) {
|
||||
deleteDirectory(file);
|
||||
}
|
||||
}
|
||||
return directoryToBeDeleted.delete();
|
||||
directoryToBeDeleted.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
spring.application.name=dirigent
|
||||
dirigent.compose.command=podman-compose
|
||||
dirigent.compose.command=docker-compose
|
||||
dirigent.deployments.cache.evict.interval=60000
|
||||
spring.profiles.active=local
|
||||
Reference in New Issue
Block a user