-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DirectorySyncer.groovy * Now returns existing matching DirectorySyncer-container if it exists. Intended to stop creation of duplicates * Bumped to 2.3.20 * Container.groovy * Switched IOUtils package pom.xml * Bumped commons-compress to 1.26.0 to work better with dockerclient lib * 1.26.1 appears to have a bug when extracting * ImageSummaryDS.groovy * Initial commit of file * ImageSummaryDS.groovy * Before updating replaceDockerUser to use prependStartupScript * ImageSummaryDS.groovy/replaceDockerUser() * Tried to switch to changing permissions on container boot, but that would mean that container has to start always start as root and then drop to other user, this grew to complex, among other things PATH/ENVs is then no longer inherited. * AbstractContainer.groovy * A helper class intended to let you create arbitrary containers AllureContainer.groovy * WIP JsmDevDeployment.groovy * A deployment for users who wish to develop for JSM JsmContainer.groovy * Fixed bug in isAppAppUploadEnabled() Container.groovy * Added new field "user" for setting docker user on creation * Helper methods for env * prepareCustomEnvVar, hasEnv DockerClientDS.groovy * Added simplified build command build() ImageSummaryDS.groovy * Improvements to replaceDockerUser() * ImageSummaryDS.groovy * Cleanup pom.xml * Bumped to 2.3.21-SNAPSHOT
- Loading branch information
1 parent
279be1b
commit 9e12884
Showing
9 changed files
with
775 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/groovy/com/eficode/devstack/container/impl/AbstractContainer.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.eficode.devstack.container.impl | ||
|
||
import com.eficode.devstack.container.Container | ||
|
||
/** | ||
* A helper class intended to let you create arbitrary containers quickly | ||
*/ | ||
class AbstractContainer implements Container { | ||
|
||
String containerName | ||
String containerMainPort = null | ||
String containerImage | ||
String containerImageTag | ||
String defaultShell | ||
|
||
|
||
AbstractContainer(String containerName, String containerMainPort, String containerImage, String containerImageTag, String defaultShell) { | ||
this.containerName = containerName | ||
this.containerMainPort = containerMainPort | ||
this.containerImage = containerImage | ||
this.containerImageTag = containerImageTag | ||
this.defaultShell = defaultShell | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/groovy/com/eficode/devstack/container/impl/AllureContainer.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.eficode.devstack.container.impl | ||
|
||
import com.eficode.devstack.container.Container | ||
import de.gesellix.docker.remote.api.ContainerCreateRequest | ||
|
||
class AllureContainer implements Container { | ||
|
||
String containerName = "Alpine" | ||
String containerMainPort = "5050" | ||
String containerImage = "frankescobar/allure-docker-service" | ||
String containerImageTag = "latest" | ||
String defaultShell = "/bin/bash" | ||
String user = "2001:2001" | ||
|
||
|
||
AllureContainer(String dockerHost = "", String dockerCertPath = "") { | ||
if (dockerHost && dockerCertPath) { | ||
assert setupSecureRemoteConnection(dockerHost, dockerCertPath): "Error setting up secure remote docker connection" | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
src/main/groovy/com/eficode/devstack/deployment/impl/JsmDevDeployment.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
package com.eficode.devstack.deployment.impl | ||
|
||
import com.eficode.devstack.container.Container | ||
import com.eficode.devstack.container.impl.AllureContainer | ||
import com.eficode.devstack.container.impl.JsmContainer | ||
import com.eficode.devstack.deployment.Deployment | ||
import com.eficode.devstack.util.DirectorySyncer | ||
import com.eficode.devstack.util.DockerClientDS | ||
import de.gesellix.docker.client.DockerClient | ||
import de.gesellix.docker.client.EngineResponseContent | ||
import de.gesellix.docker.remote.api.Volume | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
|
||
|
||
class JsmDevDeployment implements Deployment { | ||
|
||
Logger log = LoggerFactory.getLogger(this.class) | ||
String friendlyName = "JSM Development Platform" | ||
String deploymentNetworkName = "jsmdev" | ||
ArrayList<Deployment> subDeployments = [] | ||
|
||
DirectorySyncer srcSyncer | ||
ArrayList<String> srcCodePaths | ||
Volume srcCodeVolume | ||
|
||
AllureContainer allureContainer | ||
Volume allureReportVolume | ||
|
||
DockerClientDS dockerClient | ||
|
||
//Used when naming various Docker components | ||
String componentsPrefix | ||
|
||
JsmDevDeployment(String jiraBaseUrl, String dockerHost, String dockerCertPath, ArrayList<String> srcCodePaths) { | ||
|
||
componentsPrefix = AllureContainer.extractDomainFromUrl(jiraBaseUrl) | ||
|
||
allureContainer = new AllureContainer(dockerHost, dockerCertPath) | ||
allureContainer.containerName = componentsPrefix + "-reporter" | ||
dockerClient = allureContainer.dockerClient | ||
|
||
allureReportVolume = getOrCreateVolume( componentsPrefix+ "-reports") | ||
allureContainer.prepareCustomEnvVar(["CHECK_RESULTS_EVERY_SECONDS=3", "KEEP_HISTORY=1", "KEEP_HISTORY_LATEST=30"]) | ||
allureContainer.prepareVolumeMount(allureReportVolume.name, "/app/allure-results", false) | ||
|
||
|
||
srcCodeVolume = getOrCreateVolume(componentsPrefix + "-code") | ||
this.srcCodePaths = srcCodePaths | ||
|
||
subDeployments.add(new JsmH2Deployment(jiraBaseUrl, dockerHost, dockerCertPath)) | ||
jsmDeployment.jsmContainer.prepareVolumeMount(srcCodeVolume.name, "/var/atlassian/application-data/jira/scripts/", false) | ||
jsmDeployment.jsmContainer.prepareVolumeMount(allureReportVolume.name, "/var/atlassian/application-data/jira/allure-results/", false) | ||
|
||
|
||
} | ||
|
||
JsmH2Deployment getJsmDeployment() { | ||
return subDeployments.find { it instanceof JsmH2Deployment } as JsmH2Deployment | ||
} | ||
|
||
JsmContainer getJsmContainer() { | ||
return jsmDeployment.jsmContainer | ||
} | ||
|
||
|
||
@Override | ||
ArrayList<Container> getContainers() { | ||
return [srcSyncer, allureContainer, jsmContainer] | ||
} | ||
|
||
@Override | ||
void setContainers(ArrayList<Container> containers) { | ||
throw new InputMismatchException("Not implemented") | ||
} | ||
|
||
Volume getOrCreateVolume(String volumeName) { | ||
Volume volume = dockerClient.getVolumesWithName(volumeName).find { true } | ||
|
||
if (volume) { | ||
log.debug("\tFound existing volume:" + volume.name) | ||
} else { | ||
log.debug("\tCreating new volume $volumeName") | ||
EngineResponseContent<Volume> volumeResponse = dockerClient.createVolume(volumeName) | ||
volume = volumeResponse?.content | ||
assert volume: "Error creating volume $volumeName, " + volumeResponse?.getStatus()?.text | ||
log.debug("\t\tCreated volume:" + volume.name) | ||
} | ||
|
||
return volume | ||
} | ||
|
||
@Override | ||
boolean setupDeployment() { | ||
|
||
|
||
srcSyncer = DirectorySyncer.createSyncToVolume(srcCodePaths, srcCodeVolume.name, "-avh --chown=2001:2001") | ||
allureContainer.created ?: allureContainer.createContainer() | ||
allureContainer.startContainer() | ||
|
||
jsmDeployment.setupDeployment(true, false) | ||
|
||
|
||
} | ||
|
||
public static class Builder { | ||
|
||
private String jsmLicense | ||
private String jsmBaseUrl | ||
private String jsmVersion = "latest" | ||
private String jsmJvmDebugPort = "5005" | ||
private Boolean enableJsmDooD = false | ||
|
||
private Map<String, String> appsToInstall = [:] | ||
|
||
private String dockerHost | ||
private String dockerCertPath | ||
|
||
private ArrayList<String> srcCodePaths | ||
|
||
Builder(String baseUrl, String jsmLicense, ArrayList<String> srcCodePaths) { | ||
this.jsmLicense = jsmLicense | ||
this.jsmBaseUrl = baseUrl | ||
this.srcCodePaths = srcCodePaths | ||
} | ||
|
||
Builder setJsmVersion(String version) { | ||
this.jsmVersion = version | ||
return this | ||
} | ||
|
||
Builder setJsmJvmDebugPort(String port) { | ||
this.jsmJvmDebugPort = port | ||
return this | ||
} | ||
|
||
/** | ||
* Enable Docker Outside of Docker by mounting "/var/run/docker.sock" in to jsm container | ||
* @return | ||
*/ | ||
Builder enableJsmDood() { | ||
this.enableJsmDooD = true | ||
return this | ||
} | ||
|
||
|
||
Builder addAppToInstall(String appUrl, String appLicense = "") { | ||
this.appsToInstall.put(appUrl, appLicense) | ||
return this | ||
} | ||
|
||
Builder setDockerHost(String host) { | ||
this.dockerHost = host | ||
return this | ||
} | ||
|
||
Builder setDockerCertPath(String certPath) { | ||
this.dockerCertPath = certPath | ||
return this | ||
} | ||
|
||
|
||
JsmDevDeployment build() { | ||
|
||
JsmDevDeployment devDeployment = new JsmDevDeployment(jsmBaseUrl, dockerHost, dockerCertPath, srcCodePaths) | ||
|
||
devDeployment.jsmDeployment.jsmContainer.containerImageTag = this.jsmVersion | ||
devDeployment.jsmDeployment.jsmContainer.created ?: devDeployment.jsmDeployment.jsmContainer.enableJvmDebug(this.jsmJvmDebugPort) | ||
devDeployment.jsmDeployment.setJiraLicense(this.jsmLicense) | ||
devDeployment.jsmDeployment.jsmContainer.enableAppUpload() | ||
if (enableJsmDooD) { | ||
devDeployment.jsmDeployment.jsmContainer.prepareBindMount("/var/run/docker.sock", "/var/run/docker.sock", false) | ||
} | ||
devDeployment.jsmDeployment.appsToInstall = this.appsToInstall | ||
|
||
|
||
return devDeployment | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
Oops, something went wrong.