O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Into The Box 2018 | Content box + docker

287 visualizações

Publicada em

Gavin Pickin

Publicada em: Software
  • Seja o primeiro a comentar

Into The Box 2018 | Content box + docker

  1. 1. ContentBox + Docker Gavin Pickin
  2. 2. ● About Me?
  3. 3. Docker Images ● Ortus Solutions has built and supports a few docker images, the most common and popular ○ ortussolutions/commandbox https://hub.docker.com/r/ortussolutions/commandbox/ ● Ortus Solutions has built one especially for ContentBox ○ Adds several bells and whistles to help get your ContentBox app ready to deploy to docker ○ ContentBox Image updated for Version 4.0 release.
  4. 4. CommandBox Docker Image https://hub.docker.com/r/ortussolutions/commandbox/ ● Gives you commandbox, ready to go. ● Run any CF Engine or WAR file ● Use CFConfig to configure your cfml engine ● Use environment values for overrides ● Put your files in the /app directory and start the server of your choice Your app is yours, and how you set it up, config it, is all up to you.
  5. 5. ContentBox Docker Image https://hub.docker.com/r/ortussolutions/contentbox/ ContentBox’s image is built upon CommandBox, so it’s everything plus: ● Datasource config ● Distributed caching for content, rss etc ● Environment Overrides for ContentBox settings ● Embedded H2 DB support ● And more
  6. 6. Use PORTAINER https://portainer.io/ Awesome, Free Opensource Kiwi Powered :)
  7. 7. Portainer
  8. 8. ContentBox Image - Express version ● The express version uses an in memory H2 database. ● Perfect for setting up for testing. ● If you start with the express=true and install=true you can install a fresh contentbox site into the H2 database docker run -p 8080:8080 -e express=true -e install=true ortussolutions/contentbox
  9. 9. ContentBox Image - Persisting Data Docker doesn’t care about your data / files. If you want to keep it, persist it. Here we mount 2 volumes into the H2 data folder and the media folder docker run -p 8080:8080 -e express=true -e install=true -v `pwd`/contentbox-db:/data/contentbox/db -v `pwd`/contentbox-media:/app/includes/shared/media ortussolutions/contentbox
  10. 10. ContentBox Image - Environment Variables This image allows you to pass in a series of environment variables to default your values when installing ContentBox ● Express ● Install ● FWREINIT_PW ● SESSION_STORAGE ● DISTRIBUTED_CACHE ● H2_DIR ● contentbox_default_* ● ORM_SECONDARY_CACHE ● ORM_DIALECT
  11. 11. ContentBox Image - Database Connections ● To programmatically configure the database on container start, environment variables which represent your datasource configuration should be provided. There are two patterns supported: ○ DB_DRIVER configuration - which may be used for Adobe Coldfusion servers ○ DB_CLASS configuration - which configures a datasource by JDBC driver and connection string.
  12. 12. ContentBox Image - Database Connections MYSQL Setup docker run -p 8080:8080 -e 'express=true' -e 'installer=true' -e 'cfconfig_adminPassword=myS3cur3P455' -e "DB_CONNECTION_STRING=jdbc:mysql://mysqlhost:3306/contentbox_docker?useUnicode=true&characterEncoding=UT F-8&useLegacyDatetimeCode=true" -e 'DB_CLASS=org.gjt.mm.mysql.Driver' -e 'DB_USER=contentbox_user' -e 'DB_PASSWORD=myS3cur3P455' -v `pwd`/contentbox-media:/app/includes/shared/media ortussolutions/contentbox
  13. 13. ContentBox Image - Database Connections MSSQL Setup on Adobe docker run -p 8080:8080 -e 'CFENGINE=adobe@11' -e 'installer=true' -e 'cfconfig_adminPassword=myS3cur3P455' -e 'DB_DRIVER=MSSQLServer' -e 'DB_HOST=sqlserver_host' -e 'DB_PORT=1433' -e 'DB_NAME=contentbox_docker' -e 'DB_USER=sa' -e 'DB_PASSWORD=myS3cur3P455' -v `pwd`/contentbox-media:/app/includes/shared/media ortussolutions/contentbox
  14. 14. ContentBox Image - Distributed Cache ● By default, this image is configured to use the connected database as a caching storage as well. This will allow you to distribute your stack with pseudo-caching enabled. ● However, if you would like to have a real distributed cache like Redis or Couchbase connected to your images, you will need to use the appropriate CacheBox providers and your own custom CacheBox.cfc configuration file. For an example of using Redis, check out our compose repository: https://github.com/Ortus-Solutions/docker-contentbox-distributed
  15. 15. What if I have a ContentBox site already? Two Options ● Extract your changes from your old site and mount/copy them into ContentBox’s Docker Image - let’s look at that first ● Update your existing site to use some ContentBox Docker Image magic - we’ll look at this in a little while
  16. 16. Let’s startup a site with ContentBox image ● docker run -p 8080:8080 -e 'cfconfig_adminPassword=password' -e "DB_CLASS=org.gjt.mm.mysql.Driver" -e "DB_CONNECTION_STRING=jdbc:mysql:// true&characterEncoding=UTF-8&useLegacyDatetimeCode=true" -e "DB_USER=root" -e "DB_PASSWORD=secretpassword" ortussolutions/contentbox
  17. 17. Folder Structure - Where are my Files? Working with Docker where everything is in the image already is a little weird to say the least. You only need what is different in your local files ● Mount the persistent files as a volume ● Mount / Copy the Changes
  18. 18. Let’s add our Media into the Image docker run -p 8080:8080 -e 'cfconfig_adminPassword=password' -e "DB_CLASS=org.gjt.mm.mysql.Driver" -e "DB_CONNECTION_STRING=jdbc:mysql:// ncoding=UTF-8&useLegacyDatetimeCode=true" -e "DB_USER=root" -e "DB_PASSWORD=r3@lc@m@" -v c:/www/__docker_contentbox/contentbox-media:/app/includes/shared/media ortussolutions/contentbox
  19. 19. Let’s add our Theme into the Image docker run -p 8080:8080 -e 'cfconfig_adminPassword=password' -e "DB_CLASS=org.gjt.mm.mysql.Driver" -e "DB_CONNECTION_STRING=jdbc:mysql:// ncoding=UTF-8&useLegacyDatetimeCode=true" -e "DB_USER=root" -e "DB_PASSWORD=r3@lc@m@" -v c:/www/__docker_contentbox/contentbox-media:/app/includes/shared/media -v c:/www/__docker_contentbox/themes/golfnk:/app/modules_app/contentbox-custom/_themes/golfnk ortussolutions/contentbox
  20. 20. Add Magic into Existing Site How does ContentBox’s Docker Image do all of this? ● Secret - Some of this is already in ContentBox 3.7.x & more in 4.x ● You need some functions added to your Application.cfc ● You need some config added to your config/Coldbox.cfc ● You need some config added to your config/CacheBox.cfc Let’s get into it.
  21. 21. ContentBox’s ModuleConfig.cfc New functions in the ModuleConfig.cfc https://github.com/Ortus-Solutions/ContentBox/blob/development/modules/contentbox/Modul eConfig.cfc#L118
  22. 22. ContentBox’s Application.cfc New in Docker Image https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/Application.cfc Get Environment Variables from Java https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/Application.cfc#L20
  23. 23. ContentBox’s Application.cfc ( 2 ) SessionStorage from Env Variable https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/Application.cfc#L20 Include Datasource Mixin https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/Application.cfc#L56
  24. 24. ContentBox’s Application.cfc ( 3 ) Secondary ORM Cache https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/Application.cfc#L70
  25. 25. ContentBox’s Coldbox.cfc New in Docker Image https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc Load Java Env Variables https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc#L14
  26. 26. ContentBox’s Coldbox.cfc ( 2 ) FW Reinit Password https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc#L22 Distributed Cache Setting https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc#L98
  27. 27. ContentBox’s Coldbox.cfc ( 3 ) Distributed Sessions https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc#L117 ContentBox Runtime Overrides https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/Coldbox.cfc#L126
  28. 28. ContentBox’s CacheBox.cfc Normal ContentBox Cachebox.cfc https://github.com/Ortus-Solutions/ContentBox/blob/development/config/CacheBo x.cfc New in Docker Image https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/CacheBox.cfc
  29. 29. ContentBox’s CacheBox.cfc ( 2 ) Session Cache set to the DB https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/CacheBox.cfc#L55 New JDBC Cache setup for distributed Cache https://github.com/Ortus-Solutions/docker-contentbox/blob/development/resources /app/config/CacheBox.cfc#L71
  30. 30. Live coding moment of truth Deploy to the Cloud!!!! docker run -d -p 8080:8080 -e 'cfconfig_adminPassword=password' -e "DB_CLASS=org.gjt.mm.mysql.Driver" -e "DB_CONNECTION_STRING=jdbc:mysql:// ing=UTF-8&useLegacyDatetimeCode=true" -e "DB_USER=secret" -e "DB_PASSWORD=topsecret" -v /mnt/volume-sfo2-01/contentbox-media:/app/includes/shared/media -v /mnt/volume-sfo2-01/themes/golfnk:/app/modules/contentbox/themes/golfnk gpickin/cb
  31. 31. Live coding moment of truth Instance 2 docker run -d -p 8081:8080 -e 'cfconfig_adminPassword=password' -e "DB_CLASS=org.gjt.mm.mysql.Driver" -e "DB_CONNECTION_STRING=jdbc:mysql:// ing=UTF-8&useLegacyDatetimeCode=true" -e "DB_USER=secret" -e "DB_PASSWORD=topsecret" -v /mnt/volume-sfo2-01/contentbox-media:/app/includes/shared/media -v /mnt/volume-sfo2-01/themes/golfnk:/app/modules/contentbox/themes/golfnk gpickin/cb
  32. 32. Questions
  33. 33. Want More? Docker Mastery Course - https://www.udemy.com/docker-mastery/ Ortus Solutions Website - https://www.ortussolutions.com/events Slack Channel - http://boxteam.herokuapp.com/ Twitter - https://twitter.com/ortussolutions/ CF Summit 2018 ( Las Vegas ) - Talk to us about a Training after the conference
  34. 34. Thanks Thanks everyone There are a few more great sessions left, don’t miss out. Hope to see you all next year at Into the Box And CF Summit later in the year Travel Safe