Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
GOING LIVE WITH COMMANDBOX
AND DOCKER!
Fun times* in deploying real projects
* Your mileage might vary
CMDdevelop • deploy • deliver
@markdrew
mark@cmdhq.io
http://cmdhq.io
WHAT WE ARE COVERING
➤ Background
➤ Workflow
➤ Server Monitoring
➤ Configuration
➤ Caching & Session Storage
➤ Logging
➤ Con...
BACKGROUND
BACKGROUND
➤ Owned actual hardware at ISP
➤ Disaster Recovery (DR)
➤ WIDE range of platforms
➤ Range of usage patterns
➤ L...
Web app
Image Conv
Meta indexing
Image Conv
Log
WORKFLOW
TIMETABLE
Week1 Mon Tue Wed Thurs Fri
Dev Dev Dev Dev Dev Dev
QA
Infra
Week2 Mon Tue Wed Thurs Fri
Dev Dev Dev Dev Estimat...
WORKFLOW - GITFLOW (MODIFIED)!
Time
master
develop
feature X
feature Y
1
release
2 4
hot-fix
3
ENVIRONMENTS
Development Unit Test QA Live
ENVIRONMENTS
Development Unit Test QA Live
ENVIRONMENTS
Development
Development
Unit Test
Unit Test
QA
QA
Live
Live
*tomorrow
WHY DOCKER?
➤ Why move from Vagrant to
Docker?
➤ How does it help the
developer?
➤ How does it help
infrastructure team?
WHY COMMANDBOX?
➤ Shiny new toy?
➤ Configuration
➤ Smaller software surface
➤ Ability to script stuff EASIER
CLEAN UP THE CODE
➤ CFLint
➤ Git Hooks
➤ Unit tests *
*tomorrow
CLEAN UP THE CODE
➤ A static code analysis tool
for CFML
➤ Checks code against a list
of rules (which can be
customised pe...
> java -jar CFLint-1.2.3-all.jar -folder .
@markdrew
FOLDER BASED CONFIGURATION
{
"output" : [ ],
"rule" : [ ],
"excludes" : [ ],
"includes" : [ {
"code" : "FUNCTION...
GIT HOOKS
➤ Run Commandbox (or any!)
commands when performing
git actions.
➤ Awesome!
@markdrew
> box install commandbox-githooks
> cd MyProject
> git init
> box githooks install
Title Text
@markdrew
ADD IN THE HOOKS
{
"name":"MyProject",
"githooks":{
"preCommit":"!java -jar CFLint-1.2.3-all.jar -folder .”
}
}
...
SERVE WITH COMMANDBOX!
➤ server.json
➤ needs SSL
➤ Webroot isn’t the root.
➤ Needed specific Railo version
to start using i...
{
“name":"ClientApp",
"app":{
"cfengine":"Railo"
},
"web":{
“webroot":"wwwroot/",
"SSL":{
"enable":true,
"port":1443
},
"h...
@markdrew
AND CREATE DOCKER
#!/usr/bin/env bash
echo "Building the APP Docker image"
container_name="development-${RANDOM}...
@markdrew
AND CREATE DOCKER
FROM ortussolutions/commandbox
COPY . /app
buildDocker.sh
NOW WITH GITLAB
NOW WITH GITLAB
SERVER MONITORING
MONITORING
➤ It’s 3am, do you know which
server crashed?
➤ Where are the logs? Is it
VM1(x)? Which instance?
SERVER MONITORING
VM1 VM2 VM3 VM4 VM5
VM1
FUSION REACTOR CLOUD
PROMETHEUS
OTHER MONITORS
CONFIGURATION
CONFIGURATION
➤ From Database
➤ Dynamic Datasources
➤ On Request
➤ Per request settings
➤ CFConfig
➤ JVM Settings
➤ Extensi...
@markdrew
DYNAMIC DATASOURCES
component {
app = new core.objects.app();
hostName = ListFirst(cgi.http_host , ":");
appConf...
@markdrew
CFCONFIG
> box install commandbox-cfconfig
> cfconfig show
Title Text
{
"applicationListener":"mixed",
"applicationMode":"curr2root",
"applicationTimeout":"1,0,0,0",
"clientCookies":"yes",
"cl...
@markdrew
CFCONFIG
> cfconfig export .CFConfig.json
Title Text
@markdrew
CFCONFIG SETTINGS
{
"app":{
"cfengine":"Lucee@5"
}
"cfconfigfile":".CFConfig.json"
}
server.json
@markdrew
JVM SETTINGS
{
"app":{
"cfengine":"Lucee@5"
},
"jvm":{
"heapSize":1024,
"minHeapSize":256
},
"cfconfigfile":".CF...
ENVIRONMENT RESOURCE HOSTS
Dev Test QA Live
DB dev.domain test.domain qa.domain live.domain
Mail mail.dev.domain mail.test...
ENVIRONMENT RESOURCE HOSTS
Dev Test QA Live
DB db db db db
Mail mail mail mail mail
Logs logs logs logs logs
Etc etc etc e...
@markdrew
/ETC/HOSTS
192.168.2.1 db
192.168.2.1 mail
192.168.2.1 logs
192.168.2.1 etc
Hosts
@markdrew
ADD HOSTS
#!/usr/bin/env bash
echo "Building the APP Docker image"
container_name="development-${RANDOM}"
image_...
CACHING & SESSION
STORAGE
CACHING & SESSIONS
➤ Cache of data
➤ Cache of resources/artefacts
➤ Cache of function results
➤ Session storage
CACHE OF DATA
CACHE OF DATA
http://127.0.0.1:51921/lucee/admin/web.cfm?action=services.cache
@markdrew
function getConfig() cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#"{
return now();
}
Title Text
@markdrew
ARTEFACT CACHING
docker run 
—name ourapp 
-p 8080:8080 
-p 8443:8443 
-v .CommandBox/artifacts:/root/.CommandBo...
SESSION STORAGE
VM1
@markdrew
SETTING UP SESSION STORAGE
component {
this.sessionCluster = true;
this.sessionStorage = "SessionStore";
this.se...
LOGGING
LOGGING ISSUES
➤ Logs get lost
➤ Not all things are logged.
➤ Need to setup in Lucee admin
➤ Trap it using
➤ JournalD
➤ EL...
KIBANA - DASHBOARDS
KIBANA - TIME SERIES
@markdrew
<logger
appender="resource"
appender-arguments="path:{lucee-config}/logs/application.log"
layout="classic" name=...
LOAD BALANCING AND
ORCHESTRATION
LOAD BALANCING AND ORCHESTRATION
➤ Round Robin load balancing
➤ Kubernetes
➤ Could be using:
➤ Portioner
➤ Docker Compose ...
THE HARD STUFF
DATA CHANGES / WORKFLOW
➤ Some solutions:

➤ CFMigrations - Eric Peterson

➤ Versioning of database

➤ QueryBuilder (Fluen...
SCHEDULED TASKS
CANARY DEPLOYMENTS
VM1 VM2 VM3 VM4 VM5
VM1
GREEN/BLUE DEPLOYMENTS
VM1 VM2 VM3 VM4 VM5
IN SUMMARY
➤ Provide the team with the structure to succeed
➤ Provide the team with the tools to succeed
➤ Configure all th...
CMDdevelop • deploy • deliver
@markdrew
mark@cmdhq.io
http://cmdhq.io
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
Upcoming SlideShare
Loading in …5
×

of

Into The Box 2018 Going live with commandbox and docker Slide 1 Into The Box 2018 Going live with commandbox and docker Slide 2 Into The Box 2018 Going live with commandbox and docker Slide 3 Into The Box 2018 Going live with commandbox and docker Slide 4 Into The Box 2018 Going live with commandbox and docker Slide 5 Into The Box 2018 Going live with commandbox and docker Slide 6 Into The Box 2018 Going live with commandbox and docker Slide 7 Into The Box 2018 Going live with commandbox and docker Slide 8 Into The Box 2018 Going live with commandbox and docker Slide 9 Into The Box 2018 Going live with commandbox and docker Slide 10 Into The Box 2018 Going live with commandbox and docker Slide 11 Into The Box 2018 Going live with commandbox and docker Slide 12 Into The Box 2018 Going live with commandbox and docker Slide 13 Into The Box 2018 Going live with commandbox and docker Slide 14 Into The Box 2018 Going live with commandbox and docker Slide 15 Into The Box 2018 Going live with commandbox and docker Slide 16 Into The Box 2018 Going live with commandbox and docker Slide 17 Into The Box 2018 Going live with commandbox and docker Slide 18 Into The Box 2018 Going live with commandbox and docker Slide 19 Into The Box 2018 Going live with commandbox and docker Slide 20 Into The Box 2018 Going live with commandbox and docker Slide 21 Into The Box 2018 Going live with commandbox and docker Slide 22 Into The Box 2018 Going live with commandbox and docker Slide 23 Into The Box 2018 Going live with commandbox and docker Slide 24 Into The Box 2018 Going live with commandbox and docker Slide 25 Into The Box 2018 Going live with commandbox and docker Slide 26 Into The Box 2018 Going live with commandbox and docker Slide 27 Into The Box 2018 Going live with commandbox and docker Slide 28 Into The Box 2018 Going live with commandbox and docker Slide 29 Into The Box 2018 Going live with commandbox and docker Slide 30 Into The Box 2018 Going live with commandbox and docker Slide 31 Into The Box 2018 Going live with commandbox and docker Slide 32 Into The Box 2018 Going live with commandbox and docker Slide 33 Into The Box 2018 Going live with commandbox and docker Slide 34 Into The Box 2018 Going live with commandbox and docker Slide 35 Into The Box 2018 Going live with commandbox and docker Slide 36 Into The Box 2018 Going live with commandbox and docker Slide 37 Into The Box 2018 Going live with commandbox and docker Slide 38 Into The Box 2018 Going live with commandbox and docker Slide 39 Into The Box 2018 Going live with commandbox and docker Slide 40 Into The Box 2018 Going live with commandbox and docker Slide 41 Into The Box 2018 Going live with commandbox and docker Slide 42 Into The Box 2018 Going live with commandbox and docker Slide 43 Into The Box 2018 Going live with commandbox and docker Slide 44 Into The Box 2018 Going live with commandbox and docker Slide 45 Into The Box 2018 Going live with commandbox and docker Slide 46 Into The Box 2018 Going live with commandbox and docker Slide 47 Into The Box 2018 Going live with commandbox and docker Slide 48 Into The Box 2018 Going live with commandbox and docker Slide 49 Into The Box 2018 Going live with commandbox and docker Slide 50 Into The Box 2018 Going live with commandbox and docker Slide 51 Into The Box 2018 Going live with commandbox and docker Slide 52 Into The Box 2018 Going live with commandbox and docker Slide 53 Into The Box 2018 Going live with commandbox and docker Slide 54 Into The Box 2018 Going live with commandbox and docker Slide 55 Into The Box 2018 Going live with commandbox and docker Slide 56 Into The Box 2018 Going live with commandbox and docker Slide 57 Into The Box 2018 Going live with commandbox and docker Slide 58 Into The Box 2018 Going live with commandbox and docker Slide 59 Into The Box 2018 Going live with commandbox and docker Slide 60 Into The Box 2018 Going live with commandbox and docker Slide 61 Into The Box 2018 Going live with commandbox and docker Slide 62 Into The Box 2018 Going live with commandbox and docker Slide 63 Into The Box 2018 Going live with commandbox and docker Slide 64 Into The Box 2018 Going live with commandbox and docker Slide 65 Into The Box 2018 Going live with commandbox and docker Slide 66 Into The Box 2018 Going live with commandbox and docker Slide 67 Into The Box 2018 Going live with commandbox and docker Slide 68 Into The Box 2018 Going live with commandbox and docker Slide 69
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

1 Like

Share

Download to read offline

Into The Box 2018 Going live with commandbox and docker

Download to read offline

Mark Drew

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Into The Box 2018 Going live with commandbox and docker

  1. 1. GOING LIVE WITH COMMANDBOX AND DOCKER! Fun times* in deploying real projects * Your mileage might vary
  2. 2. CMDdevelop • deploy • deliver @markdrew mark@cmdhq.io http://cmdhq.io
  3. 3. WHAT WE ARE COVERING ➤ Background ➤ Workflow ➤ Server Monitoring ➤ Configuration ➤ Caching & Session Storage ➤ Logging ➤ Configuration ➤ Load Balancing and Orchestration ➤ The Hard Stuff
  4. 4. BACKGROUND
  5. 5. BACKGROUND ➤ Owned actual hardware at ISP ➤ Disaster Recovery (DR) ➤ WIDE range of platforms ➤ Range of usage patterns ➤ Lots of assets and data ➤ Issues with getting code to production ➤ 💩 code constipation ➤ 💥 Actual Disaster - ISP needs to move.
  6. 6. Web app Image Conv Meta indexing Image Conv Log
  7. 7. WORKFLOW
  8. 8. TIMETABLE Week1 Mon Tue Wed Thurs Fri Dev Dev Dev Dev Dev Dev QA Infra Week2 Mon Tue Wed Thurs Fri Dev Dev Dev Dev Estimate Train/Est QA Test Test Test Infra Week3 Mon Tue Wed Thurs Fri Dev Dev Dev Dev Dev … QA Test Test Infra Prep Deploy
  9. 9. WORKFLOW - GITFLOW (MODIFIED)! Time master develop feature X feature Y 1 release 2 4 hot-fix 3
  10. 10. ENVIRONMENTS Development Unit Test QA Live
  11. 11. ENVIRONMENTS Development Unit Test QA Live
  12. 12. ENVIRONMENTS Development Development Unit Test Unit Test QA QA Live Live *tomorrow
  13. 13. WHY DOCKER? ➤ Why move from Vagrant to Docker? ➤ How does it help the developer? ➤ How does it help infrastructure team?
  14. 14. WHY COMMANDBOX? ➤ Shiny new toy? ➤ Configuration ➤ Smaller software surface ➤ Ability to script stuff EASIER
  15. 15. CLEAN UP THE CODE ➤ CFLint ➤ Git Hooks ➤ Unit tests * *tomorrow
  16. 16. CLEAN UP THE CODE ➤ A static code analysis tool for CFML ➤ Checks code against a list of rules (which can be customised per project) ➤ Check for variable name lengths etc. ➤ https://github.com/cflint/ CFLint
  17. 17. > java -jar CFLint-1.2.3-all.jar -folder .
  18. 18. @markdrew FOLDER BASED CONFIGURATION { "output" : [ ], "rule" : [ ], "excludes" : [ ], "includes" : [ { "code" : "FUNCTION_HINT_MISSING" } ], "inheritParent" : false, "inheritPlugins" : true, "parameters" : {} } .cflintrc
  19. 19. GIT HOOKS ➤ Run Commandbox (or any!) commands when performing git actions. ➤ Awesome!
  20. 20. @markdrew > box install commandbox-githooks > cd MyProject > git init > box githooks install Title Text
  21. 21. @markdrew ADD IN THE HOOKS { "name":"MyProject", "githooks":{ "preCommit":"!java -jar CFLint-1.2.3-all.jar -folder .” } } box.json
  22. 22. SERVE WITH COMMANDBOX! ➤ server.json ➤ needs SSL ➤ Webroot isn’t the root. ➤ Needed specific Railo version to start using it (thanks Brad!)
  23. 23. { “name":"ClientApp", "app":{ "cfengine":"Railo" }, "web":{ “webroot":"wwwroot/", "SSL":{ "enable":true, "port":1443 }, "http":{ "enable":true, "port":8080 } } } server.json
  24. 24. @markdrew AND CREATE DOCKER #!/usr/bin/env bash echo "Building the APP Docker image" container_name="development-${RANDOM}" image_name="dev" docker build -t ${image_name} . echo "Starting..." docker run -it --name ${container_name} -p 8080:8080 -p 8443:1443 -v "${PWD}:/app" -v "${PWD}/../password-lgk:/usr/share/tomcat7/certs" ${image_name} buildDocker.sh
  25. 25. @markdrew AND CREATE DOCKER FROM ortussolutions/commandbox COPY . /app buildDocker.sh
  26. 26. NOW WITH GITLAB
  27. 27. NOW WITH GITLAB
  28. 28. SERVER MONITORING
  29. 29. MONITORING ➤ It’s 3am, do you know which server crashed? ➤ Where are the logs? Is it VM1(x)? Which instance?
  30. 30. SERVER MONITORING VM1 VM2 VM3 VM4 VM5 VM1
  31. 31. FUSION REACTOR CLOUD
  32. 32. PROMETHEUS
  33. 33. OTHER MONITORS
  34. 34. CONFIGURATION
  35. 35. CONFIGURATION ➤ From Database ➤ Dynamic Datasources ➤ On Request ➤ Per request settings ➤ CFConfig ➤ JVM Settings ➤ Extensions
  36. 36. @markdrew DYNAMIC DATASOURCES component { app = new core.objects.app(); hostName = ListFirst(cgi.http_host , ":"); appConfig = app.getConfig( hostName = hostName ); this.defaultDatasource = appConfig.code; this.datasources[ this.defaultDatasource ] = { class : 'com.microsoft.jdbc.sqlserver.SQLServerDriver', connectionString: 'jdbc:sqlserver://' & appConfig.dbServer & ': 1433;DATABASENAME=' & appConfig.dbName & ';sendStringParametersAsUnicode=true;SelectMethod=direct', username : appConfig.dbUser, password : appConfig.dbPassword, }; } Title Text
  37. 37. @markdrew CFCONFIG > box install commandbox-cfconfig > cfconfig show Title Text
  38. 38. { "applicationListener":"mixed", "applicationMode":"curr2root", "applicationTimeout":"1,0,0,0", "clientCookies":"yes", "clientManagement":"no", "clientTimeout":"90,0,0,0", "loggers":{ "application":{ "appender":"resource", "appenderArguments":{ "path":"{lucee-config}/logs/application.log" }, "layout":"classic" }, "datasource":{ "appender":"resource", "appenderArguments":{
  39. 39. @markdrew CFCONFIG > cfconfig export .CFConfig.json Title Text
  40. 40. @markdrew CFCONFIG SETTINGS { "app":{ "cfengine":"Lucee@5" } "cfconfigfile":".CFConfig.json" } server.json
  41. 41. @markdrew JVM SETTINGS { "app":{ "cfengine":"Lucee@5" }, "jvm":{ "heapSize":1024, "minHeapSize":256 }, "cfconfigfile":".CFConfig.json" } server.json
  42. 42. ENVIRONMENT RESOURCE HOSTS Dev Test QA Live DB dev.domain test.domain qa.domain live.domain Mail mail.dev.domain mail.test.domain mail.qa.domain mail.live.domain Logs logs.dev.domain logs.test.domain logs.qa.domain logs.live.domain Etc etc.dev.domain etc.test.domain etc.qa.domain live.qa.domain
  43. 43. ENVIRONMENT RESOURCE HOSTS Dev Test QA Live DB db db db db Mail mail mail mail mail Logs logs logs logs logs Etc etc etc etc etc
  44. 44. @markdrew /ETC/HOSTS 192.168.2.1 db 192.168.2.1 mail 192.168.2.1 logs 192.168.2.1 etc Hosts
  45. 45. @markdrew ADD HOSTS #!/usr/bin/env bash echo "Building the APP Docker image" container_name="development-${RANDOM}" image_name="dev" docker build -t ${image_name} . echo "Starting..." docker run -it --name ${container_name} -p 8080:8080 -p 8443:1443 -v "${PWD}:/app" --add-host="db:192.168.65.1" --add-host="mail:192.168.65.2" -—add-host=“logs:192.168.65.3" -—add-host=“etc:192.168.65.4” ${image_name} buildDocker.sh
  46. 46. CACHING & SESSION STORAGE
  47. 47. CACHING & SESSIONS ➤ Cache of data ➤ Cache of resources/artefacts ➤ Cache of function results ➤ Session storage
  48. 48. CACHE OF DATA
  49. 49. CACHE OF DATA http://127.0.0.1:51921/lucee/admin/web.cfm?action=services.cache
  50. 50. @markdrew function getConfig() cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#"{ return now(); } Title Text
  51. 51. @markdrew ARTEFACT CACHING docker run —name ourapp -p 8080:8080 -p 8443:8443 -v .CommandBox/artifacts:/root/.CommandBox/artifacts theapp runApp.sh
  52. 52. SESSION STORAGE VM1
  53. 53. @markdrew SETTING UP SESSION STORAGE component { this.sessionCluster = true; this.sessionStorage = "SessionStore"; this.sessionManagement = true; } Application.cfc
  54. 54. LOGGING
  55. 55. LOGGING ISSUES ➤ Logs get lost ➤ Not all things are logged. ➤ Need to setup in Lucee admin ➤ Trap it using ➤ JournalD ➤ ELK = Elasticsearch + Kibana + Logstash (beats)
  56. 56. KIBANA - DASHBOARDS
  57. 57. KIBANA - TIME SERIES
  58. 58. @markdrew <logger appender="resource" appender-arguments="path:{lucee-config}/logs/application.log" layout="classic" name="application"/> <logger appender="console" appender-arguments="streamtype:error" layout="classic" layout-arguments="" level="ERROR" name="exception"/> Title Text
  59. 59. LOAD BALANCING AND ORCHESTRATION
  60. 60. LOAD BALANCING AND ORCHESTRATION ➤ Round Robin load balancing ➤ Kubernetes ➤ Could be using: ➤ Portioner ➤ Docker Compose and Swarm ➤ Elastic Container Service AWS
  61. 61. THE HARD STUFF
  62. 62. DATA CHANGES / WORKFLOW ➤ Some solutions:
 ➤ CFMigrations - Eric Peterson
 ➤ Versioning of database
 ➤ QueryBuilder (Fluent Query Builder for CFML)  - Eric Peterson
 ➤ Currently using hand crafted SQL files (can be run multiple times)
 ➤ First time alters the columns
 ➤ Second time updates data

  63. 63. SCHEDULED TASKS
  64. 64. CANARY DEPLOYMENTS VM1 VM2 VM3 VM4 VM5 VM1
  65. 65. GREEN/BLUE DEPLOYMENTS VM1 VM2 VM3 VM4 VM5
  66. 66. IN SUMMARY ➤ Provide the team with the structure to succeed ➤ Provide the team with the tools to succeed ➤ Configure all the things! Commandbox & CfConfig are your friends ➤ Simplify environment transitions ➤ Monitor all the things! ➤ Log all the things! ➤ Cache all the things! ➤ It’s a process in process
  67. 67. CMDdevelop • deploy • deliver @markdrew mark@cmdhq.io http://cmdhq.io
  • AngeloIsaac1

    Mar. 25, 2019

Mark Drew

Views

Total views

407

On Slideshare

0

From embeds

0

Number of embeds

0

Actions

Downloads

3

Shares

0

Comments

0

Likes

1

×