From 31f92092b5beb2807cece9dfcb0cb6bcf4f18ba2 Mon Sep 17 00:00:00 2001 From: Witold Bedyk Date: Fri, 6 Jul 2018 15:17:31 +0200 Subject: [PATCH] Minor language changes and added license headers Additionally: * Move comment outside of `rm` command. Story: 2001694 Task: 22889 Change-Id: I9dd334c05bf9e209427db1b987f475e031d11d80 --- docker/Dockerfile | 4 +-- docker/README.rst | 46 +++++++++++++++++------------------ docker/example/build_image.sh | 12 +++++++++ docker/example/start.sh | 13 ++++++++++ docker/wait_for.sh | 12 +++++++++ 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index b8788b85..91d2987f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -99,11 +99,11 @@ ONBUILD RUN \ "$CONSTRAINTS_FILE"?h="$CONSTRAINTS_BRANCH" >> /VERSIONS && \ # Clean after instalation. apk del .build-deps && \ + # Pip is leaving monasca-common repo in /src so remove it. rm -rf \ /app \ /root/.cache/ \ - # Pip is leaving monasca-common repo in /src so remove it. - /src/ \ + /src/monasca-common/java/ \ /tmp/* \ /var/cache/apk/* \ /var/log/* && \ diff --git a/docker/README.rst b/docker/README.rst index d6871ea3..f2faae7c 100644 --- a/docker/README.rst +++ b/docker/README.rst @@ -5,11 +5,11 @@ Docker base image for Monasca services This image is used as a starting point for images of all Monasca services. -Building monasca-base -===================== +Building monasca-base image +=========================== -You need to have Docker installed (minimum supported version is ``17.09``). -Then you could build image inside of this folder: +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 .`` @@ -17,38 +17,38 @@ Then you could build image inside of this folder: Building child image -------------------- -In the ``example`` folder you could file sample of how to start building -new child image using ``monasca-base`` as start. +In the ``example`` folder you can find samples of how to start building +new child image using ``monasca-base``. Requirements ~~~~~~~~~~~~ -Every child image need to provide two files: +Every child image has to provide two files: start.sh - In this starting script provide all steps that direct to proper service + 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 ability to allow running container after service died - for easier debugging. + 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 status of application running in the - container. It will be useful for programs 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. + This file will be used for checking the status of the application running in + the container. 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 preinstalled: `pykafka` and `PyMySQL`. -They are used by wait scripts and in the process of creating child image -`pip3` will reinstall them to proper versions confronting to upper constraints +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. -This wait scripts will be available in every child image and could be used in +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. @@ -58,18 +58,18 @@ are started. python3 /mysql_check.py || exit 1 /wait_for.sh 192.168.10.6:5000 || exit 1 -Please, check content of every of this files for documentation of what +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 on image (you need to have ``jq`` installed): +List all labels of the image (you need to have ``jq`` installed): ``docker inspect monasca-api:master | jq .[].Config.Labels`` -Get all steps from what Docker image was build: +Get all steps of the Docker image build process history: :: diff --git a/docker/example/build_image.sh b/docker/example/build_image.sh index a0b4f844..c7145350 100755 --- a/docker/example/build_image.sh +++ b/docker/example/build_image.sh @@ -1,5 +1,17 @@ #!/bin/bash +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + # TODO(Dobroslaw): move this script to monasca-common/docker folder # and leave here small script to download it and execute using env variables # to minimize code duplication. diff --git a/docker/example/start.sh b/docker/example/start.sh index 68bbf88c..7cb3080b 100644 --- a/docker/example/start.sh +++ b/docker/example/start.sh @@ -1,4 +1,17 @@ #!/bin/sh + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + # Starting script. # All checks you need to do before service could be safely started should # be added in this file. diff --git a/docker/wait_for.sh b/docker/wait_for.sh index 8885f7b1..9205ad7d 100644 --- a/docker/wait_for.sh +++ b/docker/wait_for.sh @@ -1,5 +1,17 @@ #!/bin/sh +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + # This script will return 0 when on specific address (like 192.168.10.6:5000) # scanning will reveal that port is responding. #