-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INFRA-427: Add a new deployment type to accommodate the new Ozone pac…
…kaging (#42) * INFRA-427: Add a new deployment type to accommodate the new Ozone packaging * Allow cd to legacy docker compose folder * Add legacy Spec * Update review * Remove debug * Rename project type * Update JS doc for DockerComposeFromArtifactDeployment * Fix typo --------- Co-authored-by: Romain Buisson <[email protected]>
- Loading branch information
Showing
11 changed files
with
583 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
ARG VERSION=2.346.3 | ||
ARG VERSION=2.387.3 | ||
FROM jenkins/jenkins:$VERSION | ||
MAINTAINER Mekom Solutions <[email protected]> | ||
|
||
USER root | ||
|
||
# Add the APP_DATA_DIR volume to keep OpenMRS CD data out of the Jenkins Home | ||
ARG APP_DATA_DIR="/var/lib/openmrs_cd/app_data" | ||
RUN mkdir -p $APP_DATA_DIR && chown -R jenkins:jenkins $APP_DATA_DIR | ||
|
||
RUN apt update --fix-missing | ||
RUN apt -y install nano jq openssh-server rsync libxml2-utils | ||
|
||
|
@@ -22,6 +18,10 @@ RUN sudo apt install -y nodejs | |
# Jenkins needs to be a sudo to execute some build tasks (particularly Bahmni Apps) | ||
RUN echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
# Add the APP_DATA_DIR volume to keep OpenMRS CD data out of the Jenkins Home | ||
ARG APP_DATA_DIR="/var/lib/openmrs_cd/app_data" | ||
RUN mkdir -p $APP_DATA_DIR && chown -R jenkins:jenkins $APP_DATA_DIR | ||
|
||
# Provide access to the /usr/share/jenkins directory | ||
RUN chown -R jenkins /usr/share/jenkins | ||
|
||
|
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
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
138 changes: 138 additions & 0 deletions
138
node-scripts/spec/pipeline3/impl/dockerComposeFromArtifact.spec.js
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,138 @@ | ||
"use strict"; | ||
|
||
describe("Docker Compose Generic Deployment implementation", function() { | ||
// deps | ||
const path = require("path"); | ||
const config = require(path.resolve("src/utils/config")); | ||
const cst = require(path.resolve("src/const")); | ||
const dockerCompose = require(path.resolve( | ||
"src/pipeline3/impl/dockerComposeFromArtifact" | ||
)); | ||
|
||
const scripts = require(path.resolve( | ||
"src/" + config.getJobNameForPipeline3() + "/scripts" | ||
)); | ||
|
||
var instanceDef = { | ||
uuid: "336af1ee-90a1-4d1b-baaf-db12c84deec0", | ||
name: "cambodia1", | ||
type: "dev", | ||
group: "tlc", | ||
deployment: { | ||
hostDir: "/var/docker-volumes/", | ||
type: "dockerComposeFromArtifact", | ||
composePlugin: true, | ||
dockerComposeFiles: ["docker-compose.yml", "docker-compose-2.yml"], | ||
envFiles: ["env-file-1", "env-file-2"], | ||
value: { | ||
projectPath: "/var/docker-volumes/artifacts/run/docker", | ||
services: ["proxy", "openmrs", "mysql"] | ||
}, | ||
timezone: "Europe/Amsterdam", | ||
host: { | ||
type: "ssh", | ||
value: { | ||
ip: "hsc-dev.mekomsolutions.net", | ||
user: "mekom", | ||
port: "22" | ||
} | ||
} | ||
}, | ||
data: [ | ||
{ | ||
type: "sqlDocker", | ||
value: { | ||
service: "mysql", | ||
sourceFile: "/var/instance-data/sql-script.sql" | ||
} | ||
} | ||
] | ||
}; | ||
it("should use the correct compose command if composePlugin is set to true", () => { | ||
var expected = "docker compose"; | ||
expect(dockerCompose.composeExec(true)).toEqual(expected); | ||
}); | ||
|
||
it("should use the correct compose command if composePlugin is set to false", () => { | ||
var expected = "docker-compose"; | ||
expect(dockerCompose.composeExec(false)).toEqual(expected); | ||
}); | ||
|
||
it("should generate the correct compose command given multiple docker compose files", () => { | ||
var expected = " -f docker-compose.yml -f docker-compose-2.yml "; | ||
expect( | ||
dockerCompose.combineComposeFiles( | ||
instanceDef.deployment.dockerComposeFiles | ||
) | ||
).toEqual(expected); | ||
}); | ||
it("should generate Pre-Host Preparation deployment script", () => { | ||
var expected = ""; | ||
expected += scripts.initFolder( | ||
config.getCDDockerDirPath(instanceDef.uuid), | ||
"jenkins", | ||
"jenkins", | ||
true | ||
); | ||
|
||
expect( | ||
dockerCompose.preHostPreparation.getDeploymentScript(instanceDef) | ||
).toEqual(expected); | ||
}); | ||
|
||
it("should generate Host Preparation deployment script", () => { | ||
var expected = ""; | ||
|
||
expected += | ||
scripts.remote( | ||
instanceDef.deployment.host.value, | ||
scripts.writeProperty( | ||
"TIMEZONE", | ||
instanceDef.deployment.timezone, | ||
path | ||
.resolve(instanceDef.deployment.value.projectPath, ".env") | ||
.toString() | ||
) | ||
) + "\n"; | ||
|
||
expected += | ||
scripts.remote( | ||
instanceDef.deployment.host.value, | ||
scripts.createEnvVarFileDockerGeneric(instanceDef) | ||
) + | ||
"\n" + | ||
scripts.remote( | ||
instanceDef.deployment.host.value, | ||
"cd " + | ||
path.resolve(instanceDef.deployment.value.projectPath).toString() + | ||
" && docker compose -p " + | ||
instanceDef.name + | ||
" -f docker-compose.yml -f docker-compose-2.yml " + | ||
" --env-file=env-file-1 --env-file=env-file-2 --env-file=/var/docker-volumes/artifacts/run/docker/cambodia1.env" + | ||
" build --pull proxy openmrs mysql" + | ||
"\n" | ||
) + | ||
scripts.remote( | ||
instanceDef.deployment.host.value, | ||
"cd " + | ||
path.resolve(instanceDef.deployment.value.projectPath).toString() + | ||
" && docker compose -p " + | ||
instanceDef.name + | ||
" -f docker-compose.yml -f docker-compose-2.yml " + | ||
" --env-file=env-file-1 --env-file=env-file-2 --env-file=/var/docker-volumes/artifacts/run/docker/cambodia1.env" + | ||
" pull proxy openmrs mysql" + | ||
"\n" | ||
) + | ||
scripts.remote( | ||
instanceDef.deployment.host.value, | ||
"sudo chown -R root:root " + | ||
path | ||
.resolve(instanceDef.deployment.hostDir, instanceDef.name) | ||
.toString() | ||
); | ||
let generated = dockerCompose.hostPreparation.getDeploymentScript( | ||
instanceDef | ||
); | ||
expect(generated).toEqual(expected); | ||
}); | ||
}); |
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
Oops, something went wrong.