The main idea of the following example is to show a devops lifecycle of an infrastructure application in a production environment using Docker containers. As use case example to describe this lifecycle, we select a customized Apereo CAS 6 Server (Central Authentication System). The set of used open source tools are the following:
The lifecycle is represented in the following figure:
Let's logger.log some details tool by tool:
The starting point was CAS 6 overlay project, which is used for creating a customized CAS project in gitlab.
$ git clone https://gitlab.zylk.net/dockyard/cas-6-ldap.git
$ cd cas-6-ldap
# We use gradle for several customizations
$ build.sh getview footer
$ build.sh getview header
$ build.sh getview casViewLogin
$ build.sh getresource messages
$ build.sh getresource messages_es
$ build.sh getview loginform
# git add .
# git commit . -m "Adding changes to custom CAS 6"
# git push -u origin master
Some partial tree view of the project will be like this:
│ └── cas
│ ├── config
│ │ ├── cas.properties
│ │ └── log4j2.xml
│ ├── services
│ └── thekeystore
│ └── docker
│ └── entrypoint.sh
│ ├── css
│ │ └── cas.css
│ └── js
│ └── cas.js
Additionally we added our custom Docker resources to the project.
Dockerfile: It uses a slim image for compiling the war file, and a different tomcat image for deploying.
FROM openjdk:11-alpine as build
ADD . /cas
RUN set -x \
&& sh ./build.sh copy \
&& sh ./build.sh package
COPY --from=build /cas/build/libs/cas.war /usr/local/tomcat/webapps
docker-compose.yml: We set the Docker image to use / compile, the published port(s), volumes and extra hosts. It refers to previous Dockerfile, and it will be used in portainer infrastructure for managing the deployment.
In the compose, 9009 is the AJP port which will be proxied in Apache frontend and it also needed to define the Ldap server that is using CAS, as user directory.
# first it clones the repo
git clone https://gitlab.zylk.net/dockyard/cas-6-ldap.git
# then deploys in docker infrastructure
docker stack rm cas6
# the docker image is compiled from our private repository
docker build -t zylk/cas:6 .
docker tag zylk/cas:6 nexus3.zylk.net/zylk/cas:6
# once compiles, we push the changes to nexus
docker push nexus3.zylk.net/zylk/cas:6
# finally we deploy in portainer
docker stack deploy -c docker-compose.yml cas6
Portainer: Docker Swarm is the engine where the custom docker containers / images are being executed, while Portainer is the interface for managing the deployments. Finally, we publish /cas secured context in the Apache frontend, using the exposed ports in portainer machine.