containers: Unify container names

Signed-off-by: Till Maas <opensource@till.name>
This commit is contained in:
Till Maas 2019-04-26 18:18:57 +02:00
parent f22a3b95e2
commit 35b1de1277
8 changed files with 94 additions and 50 deletions

View File

@ -112,9 +112,8 @@ tox -e check-integ-py27
### Build a new container image
```
sudo docker build --no-cache --rm -t local/centos7-nmstate-dev .
sudo docker build --file Dockerfile.fedora --no-cache --rm \
-t local/fedora-nmstate-dev .
sudo ../packaging/build-container.sh local/centos7-nmstate-dev
sudo ../packaging/build-container.sh local/fedora-nmstate-dev
```
To test the image, either specify it manually as described above or tag it locally:

View File

@ -1,11 +0,0 @@
cd /lib/systemd/system/sysinit.target.wants/;
for i in *; do
[ $i == systemd-tmpfiles-setup.service ] || rm -f $i;
done;
rm -f /lib/systemd/system/multi-user.target.wants/*;
rm -f /etc/systemd/system/*.wants/*;
rm -f /lib/systemd/system/local-fs.target.wants/*;
rm -f /lib/systemd/system/sockets.target.wants/*udev*;
rm -f /lib/systemd/system/sockets.target.wants/*initctl*;
rm -f /lib/systemd/system/basic.target.wants/*;
rm -f /lib/systemd/system/anaconda.target.wants/*;

View File

@ -1,12 +0,0 @@
install -o root -g root -d /etc/sysconfig/network-scripts
echo -e "[logging]\nlevel=TRACE\ndomains=ALL\n" > \
/etc/NetworkManager/conf.d/97-docker-build.conf
echo -e "[device]\nmatch-device=*\nmanaged=0\n" >> \
/etc/NetworkManager/conf.d/97-docker-build.conf
echo -e "[main]\nno-auto-default=*\n" >> \
/etc/NetworkManager/conf.d/97-docker-build.conf
sed -i 's/#RateLimitInterval=30s/RateLimitInterval=0/' \
/etc/systemd/journald.conf
sed -i 's/#RateLimitBurst=1000/RateLimitBurst=0/' \
/etc/systemd/journald.conf
systemctl enable openvswitch.service

View File

@ -156,31 +156,10 @@ function is_file_changed {
fi
}
function rebuild_el7_base_container_image {
docker build --no-cache -t nmstate/centos7-nmstate-base \
-f "$PROJECT_PATH/packaging/Dockerfile.centos7-nmstate-base" \
"$PROJECT_PATH/packaging"
}
function rebuild_el7_container_image {
docker build --no-cache -t nmstate/centos7-nmstate-dev \
-f "$PROJECT_PATH/automation/Dockerfile" \
"$PROJECT_PATH/automation"
}
function rebuild_fed_container_image {
docker build --no-cache -t nmstate/fedora-nmstate-dev \
-f "$PROJECT_PATH/automation/Dockerfile.fedora" \
"$PROJECT_PATH/automation"
}
function rebuild_container_images {
if (is_file_changed "$PROJECT_PATH/packaging" ||
is_file_changed "$PROJECT_PATH/automation"); then
if is_file_changed "$PROJECT_PATH/packaging"; then
rebuild_el7_base_container_image
rebuild_el7_container_image
rebuild_fed_container_image
${PROJECT_PATH}/packaging/build-container.sh all
fi
}

View File

@ -4,6 +4,8 @@ The images are automatically rebuilt on new GIT tags or pushes to the master bra
`Dockerfile.centos7-nmstate` by https://cloud.docker.com/u/nmstate/repository/docker/nmstate/centos7-nmstate
`Dockerfile.centos7-nmstate-base` by https://cloud.docker.com/u/nmstate/repository/docker/nmstate/centos7-nmstate-base
`Dockerfile.centos7-nmstate-dev` by https://cloud.docker.com/u/nmstate/repository/docker/nmstate/centos7-nmstate-dev
`Dockerfile.fedora-nmstate-dev` by https://cloud.docker.com/u/nmstate/repository/docker/nmstate/fedora-nmstate-dev
The base image contains a common base that is used both for the development
image and for the distributed image.
@ -37,5 +39,6 @@ The Nmstate user image builds the master master branch by default. To specify a
different commit or tag, specify the `SOURCE_COMMIT` build argument:
```shell
sudo docker build --no-cache --build-arg SOURCE_COMMIT=v0.0.4 -t nmstate/centos7-nmstate -f Dockerfile.centos7-nmstate .
./build-container.sh --extra-args "--build-arg SOURCE_COMMIT=v0.0.6" nmstate/centos7-nmstate
```

86
packaging/build-container.sh Executable file
View File

@ -0,0 +1,86 @@
#! /bin/bash -e
#
# Copyright 2019 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
EXEC_PATH="$(dirname "$(realpath "$0")")"
PROJECT_PATH="$(dirname $EXEC_PATH)"
DEFAULT_BUILD_FLAGS="--no-cache --rm"
DEFAULT_TAG_PREFIX="nmstate"
options=$(getopt --options "" \
--longoptions extra-args: \
-- "${@}")
eval set -- "${options}"
while :
do
case "${1}" in
--extra-args)
shift
extra_args="${1}"
;;
--)
shift
break
;;
esac
shift
done
rebuild_container() {
local container_name
local extra_args
extra_args="${1}"
shift
# remove leading tag prefix
container_name="${1#*/}"
# remove container name suffix
echo "${1}" | grep -q "/" && tag_prefix="${1%/*}"
# assign default value in case argument did not contain a tag prefix
: ${tag_prefix:=${DEFAULT_TAG_PREFIX}}
build_tag="${tag_prefix}/${container_name}"
container_spec="$PROJECT_PATH/packaging/Dockerfile.${container_name}"
echo >/dev/stderr "Building '${container_spec}' into tag '${build_tag}'..."
docker build ${DEFAULT_BUILD_FLAGS} ${extra_args} -t "${build_tag}" \
-f "${container_spec}" "$PROJECT_PATH/packaging"
}
for container_name in "${@}"
do
if [[ "${container_name}" == "all" ]]
then
for container_name in \
centos7-nmstate-base \
centos7-nmstate-dev \
centos7-nmstate \
fedora-nmstate-dev
do
rebuild_container "${extra_args}" "${container_name}"
done
else
rebuild_container "${extra_args}" "${container_name}"
fi
done