diff --git a/examples/docker-registry/docker-compose.yml b/examples/docker-registry/docker-compose.yml new file mode 100644 index 0000000..547cb8b --- /dev/null +++ b/examples/docker-registry/docker-compose.yml @@ -0,0 +1,10 @@ +version: '2' + +services: + registry: + image: registry + ports: + - 5000 + volumes: + - /denverimaging/e3ebf132-c720-4d33-afe0-7b858eb88cdd/3dc9dd9a-802f-4dee-83dc-955f32165f08:/var/lib/registry + diff --git a/examples/docker-registry/fli-manifest.yml b/examples/docker-registry/fli-manifest.yml new file mode 100644 index 0000000..1ff3251 --- /dev/null +++ b/examples/docker-registry/fli-manifest.yml @@ -0,0 +1,10 @@ +docker_app: docker-compose.yml + +flocker_hub: + endpoint: https://data.flockerhub.clusterhq.com + tokenfile: /root/vhut.txt + +volumes: + - name: registry-mount + snapshot: docker-images + volumeset: flidocker-example-registry-6 diff --git a/examples/docker-registry/invoke.sh b/examples/docker-registry/invoke.sh new file mode 100755 index 0000000..6384ba4 --- /dev/null +++ b/examples/docker-registry/invoke.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +function fli () { + local zpool_name='denverimaging' + docker run --rm -it --privileged -v /etc/hosts:/etc/hosts -v /root:/root -v /${zpool_name}:/${zpool_name}:shared -v /var/log/fli:/var/log/fli -v /lib/modules:/lib/modules quay.io/clusterhq_prod/fli:c6a5deac3bb68b93341c8accfdde66fd7d13fc1f "$@" +} + +### Set a unique VOlumeSet and Volume name +volumeset_name='flidocker-example-registry-6' +volume_name='dockerregistry' +snapshot_name='docker-images' +flidocker_path='/tmp/fli-docker' +flockerhub_token_path='/root/vhut.txt' + +if test ! -e $flockerhub_token_path +then + echo "FlockerHub token file does not exist: ${flockerhub_token_path}" + exit 10 +fi + +### Invoke Fli-Docker +echo "$(tput setaf 6)Invoking Fli-Docker ..." +${flidocker_path} run -verbose -f fli-manifest.yml -c diff --git a/examples/docker-registry/prep.sh b/examples/docker-registry/prep.sh new file mode 100755 index 0000000..40eb3ce --- /dev/null +++ b/examples/docker-registry/prep.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +function PrepSnapshot () { + ### Create a VolumeSet and Volume + volumeset_id=`fli init ${volumeset_name} | tr -d '\r'` + volume_dir=`fli create ${volumeset_id} ${volume_name} | tr -d '\r'` + echo "$(tput setaf 6)Created VolumeSet ${volumeset_id} and Volume ${volume_dir}$(tput setaf 7)" + + ### Start a private, temporary registry instance + ### This will simply be used to stage some data onto a Fli Volume, so we can snapshot it + docker run --detach -v ${volume_dir}:/var/lib/registry -p 5000:5000 --name registry-temp registry + + ### Download Docker images locally + docker pull microsoft/powershell:centos7 + docker pull microsoft/powershell:ubuntu14.04 + docker pull microsoft/powershell:ubuntu16.04 + docker pull microsoft/powershell:latest + + docker tag microsoft/powershell:centos7 localhost:5000/microsoft/powershell:centos7 + docker tag microsoft/powershell:ubuntu14.04 localhost:5000/microsoft/powershell:ubuntu14.04 + docker tag microsoft/powershell:ubuntu16.04 localhost:5000/microsoft/powershell:ubuntu16.04 + docker tag microsoft/powershell:latest localhost:5000/microsoft/powershell:latest + + ### Push images up to the private registry instance + docker push localhost:5000/microsoft/powershell:centos7 + #docker push localhost:5000/microsoft/powershell:ubuntu14.04 + #docker push localhost:5000/microsoft/powershell:ubuntu16.04 + #docker push localhost:5000/microsoft/powershell:latest + + ### Take a snapshot of the Fli Volume + snapshot_id=`fli snapshot ${volumeset_id}:${volume_name} ${snapshot_name} | tr -d '\r'` + echo "$(tput setaf 6)Finished snapshotting the data volume ${volume_dir}. Snapshot ID is: ${snapshot_id}" + + ### Sync the VolumeSet with FlockerHub + fli sync ${volumeset_id} + echo "$(tput setaf 6)Synchronized VolumeSet (${volumeset_id}) with FlockerHub" + + ### Push the snapshot up to FlockerHub + fli push ${volumeset_id}:${snapshot_id} + echo "$(tput setaf 6)Finished pushing snapshot (${snapshot_id}), in VolumeSet (${volumeset_id}) to FlockerHub$(tput setaf 7)" +} + +PrepSnapshot