The recent launch of the Docker Init command has significantly simplified the process of generating Dockerfiles and Docker Compose templates for containerized applications. This presentation aims to explore the evolution of Docker deployment resources generation process, comparing its approach prior to the Docker Init command release and discussing the way forward. Before the introduction of the Docker Init command, I've been delivering some projects like the "alfresco-docker-installer"[1], which provides custom scripts and configurations to streamline the process of deploying Alfresco in Docker containers. These kinds of projects use tools like Yeoman or raw Python. There are some differences between a Docker Template for a technology (Go, Python, Node or Rust) and a Docker Template for a product (like Alfresco) that may be covered when generating automatic deployment resources. This presentation will delve into the methodologies employed before the Docker Init command:
Custom Dockerfile Extension
Compose Template for a complete product deployment, including a set of services like the database, content repository, search engine, or web application
Configuration Management, including techniques such as environment variable injection, externalized configuration files, and configuration overrides
Following the release of the Docker Init command, this presentation will provide insights into the possibilities and advantages it brings to complex products Docker deployment process. A PoC of a Docker Plugin, including this product-oriented approach for docker init, will be demoed live. >> Note that the Open Source Alfresco product is used only to explain the concepts of building a Docker Compose generator with a real example.
Lessons Learned from Building a Serverless Notifications System.pdf
Before & After Docker Init
1. Docker Init
Before and After
Wednesday, 4 October 2023, 11:15 - 12:00
Angel Borroy
Developer Advocate | Hyland
2. 2
Angel Borroy /Ann-Hell Borrow/
Passionate advocate for Open-Source software, actively contributing to
projects like Alfresco, Nuxeo and Hyland Experience. Angel is a Docker
Compose groupie and has been involved with Docker Community as
Docker Chapter Leader in Spain for years. Additionally, he teaches
Cryptography in the University, bridging the container gap between
academia and industry.
● Twitter https://twitter.com/AngelBorroy
● LinkedIn https://www.linkedin.com/in/angelborroy/
● GitHub https://github.com/aborroy
● Docker Hub https://hub.docker.com/u/angelborroy
Tools
EXPERIENCE
https://www.fotor.com/images/create
3. 3
A Matter of Assets
How to create Docker Assets that follow best
practices using a common approach for
Developers, DevOps engineers and Users?
4. 4
BEFORE
Python | Yeoman | Docker
DOCKER INIT
Defaults | Available Templates
AFTER
Community Templates | Wish List
8. 8
Follow the Yellow Brick Road
01 Before
PIPELINEABLE USER INTERACTION FRICTIONLESS
Python
Generate Docker Compose templates
via command line inputs, tailored for
testing within software pipelines.
Yeoman
Generate Docker Compose
templates via command line inputs
or interactive prompts, designed for
local development and testing.
Docker
Yeoman program wrapper for
simplified execution and minimizing
software requirements.
9. 9
Python
Python
PyYAML
• Designed to be used as part of the testing pipeline for Search Services
• Producing a set of Docker Compose templates with different configuration options
Template
Variables & Marks replacement
build:
context: ./${SOLR_HOST}
environment:
SOLR_ALFRESCO_PORT: "${ALFRESCO_PORT}"
JAVA_OPTS: "Populated by the generator script"
ports:
- ${EXTERNAL_PORT}:8983
01 Before
python-generator
PIPELINEABLE
USER INTERACTION
FRICTIONLESS
10. 10
Python
Execution
Command line invocation with parameters
$ python generator.py
--alfresco=alfresco/alfresco-content-repository:6.2.0
--transformer=AIOTransformers
$ tree
.
├── alfresco
│ └── Dockerfile
├── docker-compose.yml
└── search
└── Dockerfile
01 Before
python-generator
PIPELINEABLE
USER INTERACTION
FRICTIONLESS
11. 11
Yeoman
01 Before
alfresco-docker-installer
PIPELINEABLE
USER INTERACTION
FRICTIONLESS
Yeoman
npm Node.js
• Designed to be used for local development and testing using the full stack
• Producing a set of Docker Compose templates with different configuration options
Template
Variables replacement and conditional blocks
build:
context: ./search
environment:
SOLR_ALFRESCO_PORT:
<% if (solrHttpMode == 'https') { %> "8443" <% } else { %> "8080" <% } %>
JAVA_OPTS: -Dalfresco_user_store.adminpassword=<%=password%>
ports:
- <%=solrPort%>:8983
12. 12
Yeoman
01 Before
alfresco-docker-installer
PIPELINEABLE
USER INTERACTION
FRICTIONLESS
Execution
Command line invocation with parameters
$ yo alfresco-docker-installer --acsVersion=6.2 --enableContentIndexing=true
Command line invocation with interactive prompts
$ yo alfresco-docker-installer
Which ACS version do you want to use? (Use arrow keys)
7.3
❯ 7.4
How may GB RAM be available for Alfresco (16 is minimum required)? (16)
Do you want to use HTTPs for Web Proxy? (y/N)
Select the addons to be installed:
◯ Google Docs 3.1.0
❯◉ JavaScript Console 0.7
◉ Order of the Bee Support Tools 1.2.0.0
SELECT
VALUE
BOOLEAN
MULTIPLE CHOICE
14. 14
Docker
01 Before
alfresco-installer
PIPELINEABLE
USER INTERACTION
FRICTIONLESS
Docker
• Designed to minimize software requirements
Template
Variables replacement and conditional blocks
Execution
Command line invocation with interactive prompts
$ docker run -it -v $(pwd):/generated angelborroy/alfresco-installer
Which ACS version do you want to use? (Use arrow keys)
7.3
❯ 7.4
How may GB RAM be available for Alfresco (16 is minimum required)? (16)
Do you want to use HTTPs for Web Proxy? (y/N)
Select the addons to be installed:
◯ Google Docs 3.1.0
❯◉ JavaScript Console 0.7
◉ Order of the Bee Support Tools 1.2.0.0
17. 17
docker init
02 Docker Init
Available from Docker Desktop 4.18
This utility will walk you through creating the following files with defaults for your project:
- .dockerignore
- Dockerfile
- compose.yaml
? What application platform does your project use? [Use arrows to move, type to filter]
Go - suitable for a Go server application
Python - suitable for a Python server application
Node - suitable for a Node server application
Rust - suitable for a Rust server application
ASP.NET - suitable for an ASP.NET application
> Other - general purpose starting point for containerizing your application
Don't see something you need? Let us know!
18. 18
docker init
02 Docker Init
Official documentation
Closed source code
Docker Roadmap
PIPELINEABLE
FRICTIONLESS
USER INTERACTION
21. 21
Docker Init (with Templates!)
03 After
Sample Go implementation providing:
• CLI Interaction with Cobra
• Prompts Definition with YAML
• Assets Templating with Go template
• Expression Evaluation with bexpr
CLI interaction
docker init [flags]
Generates Docker Assets from a given template
Flags:
-t, --template string Name of the template to be used
-p, --prompt stringArray Property=Value list containing prompt values
-d, --directory string Local Directory containing templates to be used
-o, --output string Local Directory to write produced files
-h, --help help for init
>> Every prompt value can be used as parameter with the –p flag
PIPELINEABLE
USER INTERACTION
LOW FRICTION
docker-init-with-templates
22. 22
Docker Init (with Templates!)
03 After
CLI interaction
docker init catalog [flags]
Provides information relative to the Templates Catalog
Flags:
-t, --template string Name of the template to get details
-d, --directory string Local Directory containing templates to be used
-h, --help help for catalog
docker-init-with-templates
templates
alfresco
templates
nginx-golang-db
DOCKER CLI
Version:
label: Which ACS version do you want to use?
options:
- 7.3
- 7.4
Database:
label: Which Database engine do you want to use?
options:
- postgres
- mariadb
Messaging:
label: Do you want to use the Events service?
options:
- Yes
- No
Addons:
label: Select the addons to be installed
multiple: true
options:
- Order of the Bee Support Tools
- OCR Transformer
- Share Site Creators
Server:
label: What is the name of your server?
default: localhost
prompts.yaml
23. 23
Docker Init (with Templates!)
03 After
Template Definition
• Folder under “templates” directory with the name of the template (like “alfresco”)
• prompts.yaml file including prompts specification
• Assets to be processed using .tpl extension
templates
└── nginx-golang-db
├── README.md.tpl
├── backend
│ ├── Dockerfile.tpl
│ ├── go.mod.tpl
│ ├── go.sum.tpl
│ └── main.go.tpl
├── compose.yaml.tpl
├── db
│ └── password.txt.tpl
├── prompts.yaml
└── proxy
└── nginx.conf.tpl
docker-init-with-templates
Template name >> nginx-golang-db
Usage >> README.md
Docker Image >> Dockerfile
Source code >> main.go
Docker Compose >> compose.yaml
Prompts definition
Nice!
24. 24
Docker Init (with Templates!)
03 After
Prompts Definition
docker-init-with-templates
<id>
label: <label>
[options | default]: ...
condition: <value>
multiple: true | false
password: true | false
SELECT
PASSWORD
BOOLEAN
MULTIPLE CHOICE
VALUE
prompts.yaml
Volumes:
label: Volume method?
options:
- None
- Native
- Bind
ServerName:
label: Name of server?
default: localhost
DbPassword:
label: Type your password
password: true
Addons:
label: Addons to install
multiple: true
options:
- OCR
- Order of the Bee
Messaging:
label: Use messages?
options:
- Yes
- No
https://github.com/AlecAivazis/survey
25. 25
Docker Init (with Templates!)
03 After
Assets Templating
• Use .tpl extension
• Use expressions with values from prompts following text/template syntax
• If a template is parsed to an empty file, the file is excluded from output folder
Conditional blocks
{{- if eq .LegacyUI "Yes"}}
- ./legacy-ui/compose.yaml
{{- end}}
Values from prompts
environment:
ACTIVEMQ_ADMIN_LOGIN: "{{.MessagingUser}}"
ACTIVEMQ_ADMIN_PASSWORD: "{{.MessagingPassword}}"
docker-init-with-templates
http://networkbit.ch/golang-text-template/