monasca-common/docker
Martin Chacon Piza ccae320767 Use C compiler to build cryptography
Building wheel from cryptography>=3.4 uses by default rust compiler
but version 3.4.x keeps compatibility with C compiler by setting
the env variable CRYPTOGRAPHY_DONT_BUILD_RUST=1 [1]

[1] https://mail.python.org/pipermail/cryptography-dev/2020-December/000998.html

Change-Id: I41f47e02aef73bd9ebf6d6a46e8c212b9a268d73
2021-02-23 20:53:57 +01:00
..
example Change links usage 2019-05-28 08:41:08 +00:00
Dockerfile Use C compiler to build cryptography 2021-02-23 20:53:57 +01:00
README.rst Make health checks more frequent in Docker 2018-07-26 14:00:32 +02:00
ashrc Add base Dockerfile and supporting scripts 2018-07-09 13:49:19 +02:00
build_base_image.sh Push monasca/base image on commit, periodicaly and on release 2018-12-03 14:03:54 +01:00
kafka_wait_for_topics.py Update hacking for Python3 2020-04-24 12:41:05 +00:00
mysql_check.py Convert mysql port to int in wait script 2019-03-14 13:57:04 +01:00
wait_for.sh Support full links in Docker wait script 2019-03-12 14:00:56 +01:00

README.rst

Docker base image for Monasca services

This image is used as a starting point for images of all Monasca services.

Building monasca-base image

You need to have Docker installed (minimum tested version is 17.09). Then you can build image inside of this folder by running:

docker build --no-cache -t monasca-base:1.0.0 .

Building child image

In the example folder you can find samples of how to start building new child image using monasca-base.

Requirements

Every child image has to provide two files:

start.sh

In this starting script provide all steps that lead to the proper service start. Including usage of wait scripts and templating of configuration files. You also could provide the ability to allow running container after service died for easier debugging.

health_check.py

This file will be used for checking the status of the application running in the container. It should be used to inform Docker that service is operating and healthy. It will be useful for container orchestration like Kubernetes or Docker Swarm to properly handle services that are still running but stopped being responsive. Avoid using curl directly and instead, use health_check.py written with specific service in mind. It will provide more flexibility like when creating JSON request body.

Wait scripts

Some Python libraries are already pre-installed: pykafka and PyMySQL. They are used by wait scripts and in the process of creating the child image pip3 will reinstall them to use proper versions confronting the upper constraints file.

These wait scripts will be available in every child image and can be used in start.sh to avoid unnecessary errors and restarts of containers when they are started.

python3 /kafka_wait_for_topics.py || exit 1
python3 /mysql_check.py || exit 1
/wait_for.sh 192.168.10.6:5000 || exit 1

Please, check the content of each of these files for documentation of what environment variables are used and more usage examples.

Useful commands

List all labels of the image (you need to have jq installed):

docker inspect monasca-api:master | jq .[].Config.Labels

Get all steps of the Docker image build process history:

docker history --no-trunc <IMAGE_ID>
docker history --no-trunc monasca-base:1.0.0