Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new example: Docker Registry #53

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/docker-registry/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@wallnerryan wallnerryan Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this path be in here? Think this should be registry-mount


10 changes: 10 additions & 0 deletions examples/docker-registry/fli-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker_app: docker-compose.yml

flocker_hub:
endpoint: https://data.flockerhub.clusterhq.com
tokenfile: /root/vhut.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token.txt


volumes:
- name: registry-mount
snapshot: docker-images
volumeset: flidocker-example-registry-6
25 changes: 25 additions & 0 deletions examples/docker-registry/invoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

function fli () {
local zpool_name='denverimaging'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be configurable, as they may not want or have this as a zpool name

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these used. Not seeing where volumeset_name, volume_name or snapshot_name is used?

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
43 changes: 43 additions & 0 deletions examples/docker-registry/prep.sh
Original file line number Diff line number Diff line change
@@ -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