creating-docker-images.dita 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA General Task//EN" "generalTask.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <task id="ID">
  5. <title>Installing plug-ins in a Docker image</title>
  6. <titlealts>
  7. <navtitle>Custom images</navtitle>
  8. </titlealts>
  9. <shortdesc>To install custom plug-ins or make other changes based on the DITA-OT parent image, you can create your own
  10. <filepath>Dockerfile</filepath> and specify the official DITA-OT image as the basis for your image. </shortdesc>
  11. <prolog>
  12. <metadata>
  13. <keywords>
  14. <indexterm>plug-ins
  15. <indexterm>installing in Docker images</indexterm></indexterm>
  16. <indexterm>Docker images</indexterm>
  17. </keywords>
  18. </metadata>
  19. </prolog>
  20. <taskbody>
  21. <context>
  22. <p>Each subsequent declaration in the Dockerfile modifies this parent image, so you can start with the official
  23. image, and add custom plug-ins or other commands as required to create a custom Docker image that includes
  24. everything you need to publish your content.</p></context>
  25. <steps>
  26. <step>
  27. <cmd>Create a new <filepath>Dockerfile</filepath> and specify the official DITA-OT image in the
  28. <filepath>FROM</filepath> directive.</cmd>
  29. <stepxmp>
  30. <codeblock outputclass="language-dockerfile normalize-space show-line-numbers show-whitespace"><coderef href="../samples/docker/Dockerfile#line-range(1,2)"/></codeblock>
  31. </stepxmp>
  32. </step>
  33. <step importance="optional">
  34. <cmd>You can extend your image with a <codeph>RUN</codeph> declaration that runs the <cmdname>dita</cmdname>
  35. command from the container to install a custom plug-in, and specify the filename or URL of the plug-in’s
  36. distribution ZIP file.</cmd>
  37. <stepxmp>
  38. <codeblock outputclass="language-dockerfile normalize-space show-line-numbers show-whitespace"><coderef href="../samples/docker/Dockerfile#line-range(4,5)"/></codeblock>
  39. </stepxmp>
  40. </step>
  41. <step importance="optional">
  42. <cmd>You can also install custom plug-ins from the main DITA-OT plug-in registry at
  43. <xref keyref="site-plugin-registry"/>, or from your company plug-in registry.</cmd>
  44. <stepxmp>
  45. <codeblock outputclass="language-dockerfile normalize-space show-line-numbers show-whitespace"><coderef href="../samples/docker/Dockerfile#line-range(7,8)"/></codeblock>
  46. </stepxmp>
  47. </step>
  48. </steps>
  49. <example>
  50. <p>The <filepath>docsrc/samples</filepath> folder in the DITA-OT installation directory contains a complete
  51. example:</p>
  52. <fig>
  53. <title>Sample Dockerfile with custom plug-ins: <filepath conkeyref="conref-task/samples-dir"
  54. /><filepath>/docker/Dockerfile</filepath></title>
  55. <codeblock outputclass="language-dockerfile normalize-space show-line-numbers show-whitespace"><coderef href="../samples/docker/Dockerfile"/></codeblock>
  56. </fig>
  57. </example>
  58. <example>
  59. <title>Building a new image</title>
  60. <p>You can build a Docker image from this example by running the following command from the <filepath
  61. conkeyref="conref-task/samples-dir"/> directory:</p>
  62. <codeblock>$ <cmdname>docker</cmdname> image build -t sample-docker-image:1.0 .
  63. Sending build context to Docker daemon 2.048kB
  64. Step 1/3 : FROM docker.pkg.github.com/dita-ot/dita-ot/dita-ot:<keyword keyref="maintenance-version"/>
  65. ---> 9abb96827538
  66. Step 2/3 : RUN dita --install https://github.com/infotexture/dita-bootstrap/archive/3.3.zip
  67. ---> Running in d510f874cae0
  68. Added net.infotexture.dita-bootstrap
  69. Removing intermediate container d510f874cae0
  70. ---> 63deb8e15b5b
  71. Step 3/3 : RUN dita --install org.dita-community.pdf-page-break
  72. ---> Running in b4ef2fcad916
  73. Added org.dita-community.pdf-page-break
  74. Removing intermediate container b4ef2fcad916
  75. ---> 402885636b7f
  76. Successfully built 402885636b7f
  77. Successfully tagged sample-docker-image:1.0
  78. </codeblock>
  79. <p>Docker steps through each instruction in the Dockerfile to build the sample image. In this case, the
  80. <cmdname>dita</cmdname> command provides feedback on each installed plug-in.</p>
  81. </example>
  82. <example>
  83. <title>Running the new container</title>
  84. <p>You can then start a container based on your new image:</p>
  85. <codeblock>$ <cmdname>docker</cmdname> container run -it \
  86. -v /path/to/dita-ot-dir/docsrc:/src sample-docker-image:1.0 \
  87. -i /src/userguide.ditamap \
  88. -o /src/out/dita-bootstrap \
  89. -f html5-bootstrap -v</codeblock>
  90. <p>This command sequence specifies the following options:
  91. <ul>
  92. <li><option>-v</option> mounts the <filepath>docsrc</filepath> subfolder of the DITA-OT directory on your host
  93. machine and binds it to the <filepath>/src</filepath> volume in the container</li>
  94. <li><option>-i</option> specifies <filepath conkeyref="conref-task/docsrc-dir"
  95. /><filepath>/userguide.ditamap</filepath> as the input map file</li>
  96. <li><option>-o</option> writes the output to <filepath conkeyref="conref-task/docsrc-dir"
  97. /><filepath>/out/dita-bootstrap</filepath></li>
  98. <li><option>-f</option> sets the output format to the Bootstrap template, and</li>
  99. <li><option>-v</option> displays build progress messages with verbose logging</li>
  100. </ul>
  101. </p>
  102. <p>When the build is finished, you should find a copy of the DITA-OT documentation under <filepath
  103. conkeyref="conref-task/docsrc-dir"/><filepath>/out/dita-bootstrap</filepath>, styled with the basic Bootstrap
  104. template from the custom plug-in.</p>
  105. </example>
  106. </taskbody>
  107. </task>