From 1a5f018a203701557bb4a29c98e9e425665902e0 Mon Sep 17 00:00:00 2001 From: Eliska Slobodova Date: May 11 2017 13:21:48 +0000 Subject: [PATCH 1/2] Updated The Building container locally chapter --- diff --git a/source/development/building-modules/containers-local.rst b/source/development/building-modules/containers-local.rst index 4de1ded..622f28d 100644 --- a/source/development/building-modules/containers-local.rst +++ b/source/development/building-modules/containers-local.rst @@ -2,72 +2,48 @@ Building containers locally =============================== When you have your module built, let's put it in a container, so we can -use it. +use it. As an example, we will use the `perl image `__. -Architecture ------------- +RPM repository +-------------- -The final result of this guide is a container using a three-layer module -container architecture which clearly separates the system base image -(built out of a Base Runtime), the module itself (the one we are going -to build), and the final configuration. +First, upload your RPM repository from the previous step somewhere publicly accessible. -Examples for each layer: `Layer -1 `__ \| -`Layer 2 `__ -\| `Layer 3 `__ +Dockerfile +---------- -.. figure:: three-layer-arch.png - :alt: three-layer-arch.png - :width: 800px +Next step will be writing a Dockerfile to build a container image with your module. +The Base Runtime image is currently only available from Docker Hub and you can use it as your base image by specifying ``FROM /baseruntime/baseruntime``. -Building --------- +You also need to write a repo file for your module and add it to your container, so you can install the module in it. +See the example of the repo file in ``__. +The following snippet then shows how you copy the repo and install the files from it in your container: -Building Layer 2 -^^^^^^^^^^^^^^^^ +:: -First, upload your RPM repository from the previous step somewhere -publicly accessible. I've used my `Fedorapeople to host my modular -packages `__. + COPY repos/* /etc/yum.repos.d/ + # Perl and build tools install + user addition + RUN BUILD_TOOlS="bsdtar \ + findutils \ + gcc \ + make \ + gettext \ + tar \ + wget \ + python " && \ + microdnf --nodocs --enablerepo perl install perl perl-devel && \ + microdnf --nodocs --enablerepo fedora install -y mod_perl cpan cpanminus httpd \ + $BUILD_TOOlS && \ + microdnf clean all + RUN mkdir -p /opt/app-root/src/ && \ + useradd -u 1002 -r -g 0 -d /opt/app-root/src -s /sbin/nologin \ + -c "Default Application User" default && \ + chown -R 1002:0 /opt/app-root -Next step will be writing a Dockerfile to build a container image with -your module. This container will be representing the Layer 2 in the -three-layer architecture. -Since there is no official Base Runtime image, I have created `my own -Fake Base -Runtime `__ -that you can use as your base image by specifying -"``FROM asamalik/fake-gen-core-module``". +Building the image +------------------- -You also need to write a repo file for your module - see the example -below - and add it to your container, so you can install the module in -it. - -Basically, you need to prepare a repository similar to this example: - -- `The whole Layer 2 - repository `__ - - - `Dockerfile `__ - - `repo - file `__ - -When you have your Layer 2 repository ready, use "``docker build .``" to -build the container image and "``docker tag username/imagename``" so you -(and maybe other people) can use it as a base for the final layer. - -Building Layer 3 -^^^^^^^^^^^^^^^^ - -The final layer will not install anything, it will just add -configuration and the RUN statement to make the image work. You need to -use your Layer 2 image as a base for this one. - -An `example for the proftpd -container `__. - -And again, when you have your Dockerfile ready, use "``docker build .``" -to build the container image. +When you have your repository and Dockerfile ready, use "``docker build .``" to +build the container image and "``docker tag username/imagename``" so to make it available for public to pull. From 55cbb8f1ca9d80a2b22c67c9a29fb01fd2eab13c Mon Sep 17 00:00:00 2001 From: Eliska Slobodova Date: May 11 2017 14:09:41 +0000 Subject: [PATCH 2/2] Fixes as per feedback --- diff --git a/source/development/building-modules/containers-local.rst b/source/development/building-modules/containers-local.rst index 622f28d..4311da8 100644 --- a/source/development/building-modules/containers-local.rst +++ b/source/development/building-modules/containers-local.rst @@ -4,10 +4,17 @@ Building containers locally When you have your module built, let's put it in a container, so we can use it. As an example, we will use the `perl image `__. -RPM repository +Module RPM repository -------------- -First, upload your RPM repository from the previous step somewhere publicly accessible. +First, upload your RPM repository from the previous step somewhere publicly accessible. For example, you can use Fedorapeople to host your packages: + +:: + + $ mkdir module + $ cp $RPMS module/ + $ createrepo_c module/ + $ rsync ./module/ $USER@fedorapeople.org:public_html/ Dockerfile ---------- @@ -32,18 +39,18 @@ The following snippet then shows how you copy the repo and install the files fro tar \ wget \ python " && \ - microdnf --nodocs --enablerepo perl install perl perl-devel && \ - microdnf --nodocs --enablerepo fedora install -y mod_perl cpan cpanminus httpd \ - $BUILD_TOOlS && \ - microdnf clean all + microdnf --nodocs --enablerepo perl install perl perl-devel && \ + microdnf --nodocs --enablerepo fedora install -y mod_perl cpan cpanminus httpd \ + $BUILD_TOOlS && \ + microdnf clean all RUN mkdir -p /opt/app-root/src/ && \ - useradd -u 1002 -r -g 0 -d /opt/app-root/src -s /sbin/nologin \ - -c "Default Application User" default && \ - chown -R 1002:0 /opt/app-root + useradd -u 1002 -r -g 0 -d /opt/app-root/src -s /sbin/nologin \ + -c "Default Application User" default && \ + chown -R 1002:0 /opt/app-root Building the image ------------------- -When you have your repository and Dockerfile ready, use "``docker build .``" to -build the container image and "``docker tag username/imagename``" so to make it available for public to pull. +Finally, when you have your repository and Dockerfile ready, use the ``docker build --tag=`` command to +build the container image.