introduce a new build mechanism
This patch replaces the collection of individual "build" scripts with a single script (tools/build-docker-image), made available as "build" inside each image directory. The build-docker-image script will, by default, build images tagged with the current commit id in order to prevent developers from accidentally stepping on each other or on release images. Documentation in docs/image-building.md describes the script in more detail. Change-Id: I444d5c2256a85223f8750a0904cb4b07f18ab67f
This commit is contained in:
parent
9ce465d544
commit
24b6db92bc
34
docker/build
34
docker/build
@ -1,34 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# If the directories were numbered, a simple find could be used to build ;-)
|
|
||||||
push=
|
|
||||||
|
|
||||||
CONTAINERS=(fedora-rdo-base cinder glance/glance-base glance/glance-api glance/glance-registry heat/heat-base heat/heat-api heat/heat-engine keystone mariadb rabbitmq swift/swift-base swift/swift-account swift/swift-container swift/swift-object swift/swift-proxy-server nova-compute/nova-base nova-compute/nova-compute nova-compute/nova-libvirt)
|
|
||||||
|
|
||||||
|
|
||||||
while getopts "hp" opt > /dev/null 2>&1; do
|
|
||||||
case $opt in
|
|
||||||
p)
|
|
||||||
push=yes
|
|
||||||
;;
|
|
||||||
h)
|
|
||||||
cat <<EOF
|
|
||||||
$0 script will build all kolla docker images optionally if you specify the -p
|
|
||||||
option and you have access to the kubeglue docker namespace you will be able to
|
|
||||||
push the image in docker registry.
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
for IMAGE in ${CONTAINERS[@]}; do
|
|
||||||
pushd .
|
|
||||||
cd ${IMAGE}
|
|
||||||
echo "Building $IMAGE"
|
|
||||||
./build
|
|
||||||
if [[ ${push} == yes ]] ;then
|
|
||||||
echo "Pushing $IMAGE"
|
|
||||||
./push
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
done
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-cinder .
|
|
1
docker/cinder/build
Symbolic link
1
docker/cinder/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-cinder .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-base .
|
|
1
docker/fedora-rdo-base/build
Symbolic link
1
docker/fedora-rdo-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-base .
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
for image in glance-base glance-api glance-registry; do
|
|
||||||
(
|
|
||||||
pushd $image
|
|
||||||
./build
|
|
||||||
popd
|
|
||||||
)
|
|
||||||
done
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-glance-api .
|
|
1
docker/glance/glance-api/build
Symbolic link
1
docker/glance/glance-api/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-glance-api .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-glance-base .
|
|
1
docker/glance/glance-base/build
Symbolic link
1
docker/glance/glance-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-glance-base .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-glance-registry .
|
|
1
docker/glance/glance-registry/build
Symbolic link
1
docker/glance/glance-registry/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-glance-registry .
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
for image in glance-base glance-api glance-registry; do
|
|
||||||
(
|
|
||||||
pushd $image
|
|
||||||
./push
|
|
||||||
popd
|
|
||||||
)
|
|
||||||
done
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-heat-api .
|
|
1
docker/heat/heat-api/build
Symbolic link
1
docker/heat/heat-api/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-heat-api .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-heat-base .
|
|
1
docker/heat/heat-base/build
Symbolic link
1
docker/heat/heat-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-heat-base .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-heat-engine .
|
|
1
docker/heat/heat-engine/build
Symbolic link
1
docker/heat/heat-engine/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-heat-engine .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-keystone .
|
|
1
docker/keystone/build
Symbolic link
1
docker/keystone/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-keystone .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-mariadb .
|
|
1
docker/mariadb/build
Symbolic link
1
docker/mariadb/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-mariadb .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-nova-compute .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-nova-base .
|
|
1
docker/nova-compute/nova-base/build
Symbolic link
1
docker/nova-compute/nova-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-nova-base .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-nova-compute .
|
|
1
docker/nova-compute/nova-compute/build
Symbolic link
1
docker/nova-compute/nova-compute/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-nova-compute .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-nova-libvirt .
|
|
1
docker/nova-compute/nova-libvirt/build
Symbolic link
1
docker/nova-compute/nova-libvirt/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-nova-libvirt .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-nova-compute .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-rabbitmq .
|
|
1
docker/rabbitmq/build
Symbolic link
1
docker/rabbitmq/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-rabbitmq .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag rhel-osp-base .
|
|
1
docker/rhel-osp-base/build
Symbolic link
1
docker/rhel-osp-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-swift-account-server .
|
|
1
docker/swift/swift-account/build
Symbolic link
1
docker/swift/swift-account/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-swift-account .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-swift-base .
|
|
1
docker/swift/swift-base/build
Symbolic link
1
docker/swift/swift-base/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-swift-base .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-swift-container-server .
|
|
1
docker/swift/swift-container/build
Symbolic link
1
docker/swift/swift-container/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-swift-container .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-swift-object-server .
|
|
1
docker/swift/swift-object/build
Symbolic link
1
docker/swift/swift-object/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-swift-object .
|
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build --tag kollaglue/fedora-rdo-swift-proxy-server .
|
|
1
docker/swift/swift-proxy-server/build
Symbolic link
1
docker/swift/swift-proxy-server/build
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../tools/build-docker-image
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker push kollaglue/fedora-rdo-swift-proxy .
|
|
75
docs/image-building.md
Normal file
75
docs/image-building.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Image building
|
||||||
|
|
||||||
|
The `tools/build-docker-image` script in this repository is
|
||||||
|
responsible for building docker images. It is symlinked as `./build`
|
||||||
|
inside each Docker image directory.
|
||||||
|
|
||||||
|
When creating new image directories, you can run the
|
||||||
|
`tools/update-build-links` scripts to install the `build` symlink
|
||||||
|
(this script will install the symlink anywhere it find a file named
|
||||||
|
`Dockerfile`).
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
In general, you will build images like this:
|
||||||
|
|
||||||
|
$ cd docker/keystone
|
||||||
|
$ ./build
|
||||||
|
|
||||||
|
By default, the above command would build
|
||||||
|
`kollaglue/fedora-rdo-keystone:CID`, where `CID` is the current short
|
||||||
|
commit ID. That is, given:
|
||||||
|
|
||||||
|
$ git rev-parse HEAD
|
||||||
|
76a16029006a2f5d3b79f1198d81acb6653110e9
|
||||||
|
|
||||||
|
The above command would generate
|
||||||
|
`kollaglue/fedora-rdo-keystone:76a1602`. This tagging is meant to
|
||||||
|
prevent developers from stepping on each other or on release images
|
||||||
|
during the development process.
|
||||||
|
|
||||||
|
To push the image after building, add `--push`:
|
||||||
|
|
||||||
|
$ ./build --push
|
||||||
|
|
||||||
|
To use these images, you must specify the tag in your `docker run`
|
||||||
|
commands:
|
||||||
|
|
||||||
|
$ docker run kollaglue/fedora-rdo-keystone:76a1602
|
||||||
|
|
||||||
|
Or in your kubernetes configurations:
|
||||||
|
|
||||||
|
"containers": [{
|
||||||
|
"name": "keystone",
|
||||||
|
"image": "kollaglue/fedora-rdo-keystone:76a1602",
|
||||||
|
"ports": [
|
||||||
|
{"containerPort": 5000},
|
||||||
|
{"containerPort": 35357}
|
||||||
|
],
|
||||||
|
"env": [
|
||||||
|
{"name": "DB_ROOT_PASSWORD", "value": "password"},
|
||||||
|
{"name": "KEYSTONE_ADMIN_TOKEN", "value": "ADMINTOKEN"}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
|
||||||
|
## Building releases
|
||||||
|
|
||||||
|
To build into the `latest` tag, add `--release`:
|
||||||
|
|
||||||
|
$ ./build --release
|
||||||
|
|
||||||
|
Or to build and push:
|
||||||
|
|
||||||
|
$ ./build --push --release
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The `build-docker-image` script will look for a file named `.buildconf`
|
||||||
|
in your current directory and in the top level of the repository. You
|
||||||
|
can use this to set defaults, such as:
|
||||||
|
|
||||||
|
NAMESPACE=larsks
|
||||||
|
|
||||||
|
This setting would cause all images to be tagged into the `larsks/`
|
||||||
|
namespace.
|
||||||
|
|
94
tools/build-docker-image
Executable file
94
tools/build-docker-image
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
NAMESPACE=kollaglue
|
||||||
|
PREFIX=fedora-rdo-
|
||||||
|
TAG=$(git rev-parse --short HEAD)
|
||||||
|
IMAGE="${PREFIX}${PWD##*/}"
|
||||||
|
|
||||||
|
TOPDIR=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
cat <<EOF
|
||||||
|
$0: usage: $0 [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
--namespace, -n <namespace>
|
||||||
|
--tag, -t <tag>
|
||||||
|
--push, -p
|
||||||
|
--no-cache, -N
|
||||||
|
--release
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -f ./.buildconf ] && . ./.buildconf
|
||||||
|
[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf
|
||||||
|
|
||||||
|
ARGS=$(getopt -o 'n:t:pN' -l help,namespace:,push,release,tag:,no-cache -- "$@") || { usage >&2; exit 2; }
|
||||||
|
|
||||||
|
eval set -- "$ARGS"
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
case "$1" in
|
||||||
|
|
||||||
|
(--help) usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--release) MODE=release
|
||||||
|
TAG=latest
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--tag|-t) shift
|
||||||
|
TAG="$1"
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--push|-p) PUSH=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--no-cache|-N)
|
||||||
|
BUILDFLAGS="${BUILDFLAGS} --no-cache"
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--namespace|-n)
|
||||||
|
shift
|
||||||
|
NAMESPACE="1"
|
||||||
|
;;
|
||||||
|
|
||||||
|
(--) break
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
FULLIMAGE="${NAMESPACE}/${IMAGE}${TAG:+:${TAG}}"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
======================================================================
|
||||||
|
$FULLIMAGE
|
||||||
|
======================================================================
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ "$MODE" = "release" ]; then
|
||||||
|
echo "*** YOU ARE BUILDING A RELEASE IMAGE ***"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" .; then
|
||||||
|
echo "ERROR: failed to build $FULLIMAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Built: $FULLIMAGE"
|
||||||
|
|
||||||
|
if [ "$PUSH" = 1 ]; then
|
||||||
|
if ! docker push "$FULLIMAGE"; then
|
||||||
|
echo "ERROR: failed to push $FULLIMAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pushed: $FULLIMAGE"
|
||||||
|
fi
|
10
tools/update-build-links
Executable file
10
tools/update-build-links
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd $(git rev-parse --show-toplevel)
|
||||||
|
find docker -name Dockerfile | while read dockerfile; do
|
||||||
|
dir=${dockerfile%/*}
|
||||||
|
link=$(python -c 'import os,sys; print os.path.relpath(sys.argv[1], sys.argv[2])' \
|
||||||
|
$PWD/tools/build-docker-image $dir)
|
||||||
|
ln -sf $link $dir/build
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user