Browse Source

Keep the repos of the images

master
meskio 3 years ago
parent
commit
721734b585
Signed by: meskio
GPG Key ID: 52B8F5AC97A2DA86
  1. 17
      base_image.run
  2. 8
      build_image.run
  3. 26
      check_updates
  4. 16
      check_updates.run
  5. 20
      playbook.yml
  6. 4
      update_images

17
base_image.run

@ -1,22 +1,9 @@
#!/bin/bash -x
ROOTPATH="$WORKSPACE/rootfs"
ROOTPATH="rootfs"
PATH=$PATH:/usr/sbin
image="debian"
if [ -d ${ROOTPATH} ]
then
sudo debuerreotype-apt-get ${ROOTPATH} update
sudo debuerreotype-apt-get ${ROOTPATH} upgrade --assume-no
if [ $? -eq 0 ]
then
echo "No updates needed"
exit 0
fi
sudo rm -rf ${ROOTPATH}
fi
sudo debuerreotype-init ${ROOTPATH} stable `date +%FT%T`
sudo debuerreotype-minimizing-config ${ROOTPATH}
sudo debuerreotype-gen-sources-list ${ROOTPATH} stable 'http://deb.debian.org/debian' 'http://security.debian.org/debian-security'
@ -26,4 +13,6 @@ docker tag ${image} {{ registry_domain }}/${image}
docker tag ${image} {{ registry }}/${image}
docker push {{ registry }}/${image}
sudo rm -rf ${ROOTPATH}
update_images ${image}

8
build_image.run

@ -1,7 +1,11 @@
#!/bin/bash -ex
git clone {{ repos_url }}/${image}.git
cd ${image}
if [ ! -d {{ laminar_home }}/repos/${image} ]
then
git clone {{ repos_url }}/${image}.git {{ laminar_home }}/repos/${image}
fi
cd {{ laminar_home }}/repos/${image}
git pull
for commit in `git log --format=%H`
do

26
check_updates

@ -0,0 +1,26 @@
#!/bin/bash -x
image=$1
docker run --entrypoint /bin/bash -u root {{ registry_domain }}/$image -c "apt-get update; apt-get upgrade --assume-no"
if [ $? -eq 1 ]
then
echo "update ${image}"
if [ "$image" == "debian" ]
then
laminarc queue base_image
else
build_image $image
fi
exit 0
fi
echo "check for updates of child images of ${image}"
base="{{ registry_domain }}/$1"
for i in `curl -s -X GET {{ registry }}/v2/_catalog | jq -r '.repositories[]'`
do
if [ ! -z "`grep "FROM ${base}" {{ laminar_home }}/repos/${i}/Dockerfile`" ]
then
check_updates $i
fi
done

16
check_updates.run

@ -1,15 +1,3 @@
#!/bin/bash -x
#!/bin/bash -ex
for image in `curl -s -X GET {{ registry_domain }}/v2/_catalog | jq -r '.repositories[]'`
do
if [ "$image" == "debian" ]
then
continue
fi
docker run --entrypoint /bin/bash -u root {{ registry_domain }}/$image -c "apt-get update; apt-get upgrade --assume-no"
if [ $? -eq 1 ]
then
build_image $image
fi
done
check_updates "debian"

20
playbook.yml

@ -95,7 +95,7 @@
apt:
# laminar is in it's way to get included in debian:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919181
deb: https://github.com/ohwgiles/laminar/releases/download/0.7/laminar-0.7-1-amd64.deb
deb: https://github.com/ohwgiles/laminar/releases/download/0.7/laminar-0.7-1-amd64.deb
- name: add laminar to docker group
user: name=laminar group=docker
@ -119,6 +119,14 @@
regexp: '^laminar '
line: 'laminar ALL=(ALL) NOPASSWD: ALL'
- name: create the repos folder for laminar jobs
file:
path: "{{ laminar_home }}/repos"
state: directory
owner: laminar
group: laminar
mode: u=rwx,g=rx,o=rx
- name: configure laminar scripts
template:
src: "{{ item }}"
@ -128,6 +136,7 @@
mode: u=rwx,g=rwx,o=rx
with_items:
- update_images
- check_updates
- name: configure jobs
template:
@ -144,17 +153,10 @@
- name: enable laminar
service: name=laminar state=started enabled=yes
- name: set nightly base image rebuild
cron:
name: "rebuild base image"
hour: "2"
minute: "0"
job: "/usr/bin/laminarc queue base_image"
- name: set nightly check for image updates
cron:
name: "check image updates"
hour: "5"
hour: "2"
minute: "0"
job: "/usr/bin/laminarc queue check_updates"

4
update_images

@ -1,10 +1,10 @@
#!/bin/bash -e
#!/bin/bash -ex
base="{{ registry_domain }}/$1"
for image in `curl -s -X GET {{ registry }}/v2/_catalog | jq -r '.repositories[]'`
do
if [ ! -z "`curl -s {{ repos_url }}/${image}/raw/branch/master/Dockerfile |grep "FROM ${base}"`" ]
if [ ! -z "`grep "FROM ${base}" {{ laminar_home }}/repos/${image}/Dockerfile`" ]
then
build_image $image
fi

Loading…
Cancel
Save