Skip to content

Commit

Permalink
Added documentation for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-rodriguez committed Dec 11, 2018
1 parent 700a29b commit fdad556
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Use them at your own risk.

== Deployment

=== From code

This application can be easily deployed using **Docker** and **docker-compose**.

`$ docker-compose up`
Expand All @@ -64,3 +66,13 @@ fdb63e26d299 mythaistar_angular "nginx -g 'daemon of…" 3 minu
```

The usage of the `reverse-proxy` only uses 1 port of the Docker host (where this is deployed), the `8080`. All internal communication of containers is done using docker alias of services.

=== From artifact

If we are using a CICD pipeline and we store the artifact on nexus, we can also deploy it without recompile all code. For this purpose there are three deployment pipelines:

- deployment: deploy all application with a reserve-proxy
- java: deploy only the java application
- angular: deploy angular application + reverse-proxy (you must run the java deployment at least once before running this deployment)

The result of this deployment will be the same as in the deployment from code, but instead of compiling the artifact again downloads it from nexus. All resources (docker-compose.yml, Dockerfiles and nginx.conf) are stored in the reverse-proxy folder.
17 changes: 17 additions & 0 deletions jenkins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ In order to run all pipelines, we have installed the following plugins (maybe no
- Xvnc plugin (xvnc)
- Dashboard for Blue Ocean (blueocean-dashboard)
- Script Security Plugin (script-security)
- **HTTP Request Plugin (http_request)**

Most of them come pre-installed with the production line instance. The ones we need are the ones related to the pipeline and the ones in bold.

Expand All @@ -169,6 +170,22 @@ Most of them come pre-installed with the production line instance. The ones we n
You only need to create a new pipeline and modify the configuration following the image:
![](./pipeline-config.png)

Or you can execute the create-pipelines.sh as follows:

```bash
$ ./create-pipelines.sh <jenkinsUrl> <username> <password>
```

example:

```bash
$ ./create-pipelines.sh devon.s2-eu.capgemini.com/jenkins devonfw capgemini
```

**Important:** you need a bash shell in order to execute the command. If you are using windows, you can open a new bash shell in the devonfw console:
![console](./console.png)


**TIP**: All environment variables used on both Jenkinsfiles should be declared in the correspondant Jenkins Pipeline configuration more or less like this:

![](./jenkins-pipelines-params.png)
Binary file added jenkins/console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 18 additions & 4 deletions jenkins/create-pipelines.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@

if [ $# -ne 3 ]
then
echo "Please invoke this script with three arguments."
echo "create-pipelines <jenkinsUrl> <user> <password>"
exit -1
fi

CRUMB=$(curl -s 'https://devon.s2-eu.capgemini.com/jenkins/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)' -u $1:$2)
curl -s -XPOST 'https://devon.s2-eu.capgemini.com/jenkins/createItem?name=MTS2' -u $1:$2 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST 'https://devon.s2-eu.capgemini.com/jenkins/job/MTS2/createItem?name=CICD' -u $1:$2 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST 'https://devon.s2-eu.capgemini.com/jenkins/job/MTS2/createItem?name=deployment' -u $1:$2 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
JENKINS_URL=$1
REQUEST="https://$JENKINS_URL"
ENDING='/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
CRUMB=$(curl -s "$REQUEST$ENDING" -u $2:$3)
curl -s -XPOST "https://$JENKINS_URL/createItem?name=MTS" -u $2:$3 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/createItem?name=CICD" -u $2:$3 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/createItem?name=deployment" -u $2:$3 --data-binary @./folder.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/job/CICD/createItem?name=angular" -u $2:$3 --data-binary @./angular/cicd/pipeline.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/job/CICD/createItem?name=java" -u $2:$3 --data-binary @./java/cicd/pipeline.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/job/deployment/createItem?name=angular" -u $2:$3 --data-binary @./angular/deployment/pipeline.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/job/deployment/createItem?name=java" -u $2:$3 --data-binary @./java/deployment/pipeline.xml -H "$CRUMB" -H "Content-Type:text/xml"
curl -s -XPOST "https://$JENKINS_URL/job/MTS/job/deployment/createItem?name=deployment" -u $2:$3 --data-binary @./deployment/pipeline.xml -H "$CRUMB" -H "Content-Type:text/xml"
4 changes: 2 additions & 2 deletions jenkins/deployment/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pipeline{
sshAgentCredentials = '3d0fa2a4-5cf0-4cf5-a3fd-23655eb33c11'

// Java Deploy Pipeline name
javaDeployPipeline = 'deployment_java'
javaDeployPipeline = 'java'
// Angular Deploy Pipeline name
angularDeployPipeline = 'deployment_angular'
angularDeployPipeline = 'angular'
}

parameters {
Expand Down
2 changes: 1 addition & 1 deletion reverse-proxy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3'
services:
web:
reverse-proxy:
build: .
image: my-thai-star/reverse-proxy:latest
restart: always
Expand Down

0 comments on commit fdad556

Please sign in to comment.