mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-08-22 05:56:24 +00:00
Add ciao launcher container
Signed-off-by: Munoz, Obed N <obed.n.munoz@intel.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
FROM clearlinux/ciao-common
|
||||
MAINTAINER obed.n.munoz@intel.com
|
||||
|
||||
ARG swupd_args
|
||||
|
||||
COPY *.sh /root/
|
||||
COPY dnsmasq.conf.macvlan0 /etc/dnsmasq.conf
|
||||
|
||||
CMD '/root/launcher.sh'
|
||||
@@ -0,0 +1,66 @@
|
||||
CIAO Launcher
|
||||
=============
|
||||
[](http://microbadger.com/images/clearlinux/ciao-launcher "Get your own image badge on microbadger.com")
|
||||
[](http://microbadger.com/images/clearlinux/launcher "Get your own version badge on microbadger.com")
|
||||
|
||||
This provides a CIAO Launcher container
|
||||
|
||||
Features
|
||||
--------
|
||||
- From source building solution
|
||||
- Daemon and Manual service start mode
|
||||
- You mess it, just destroy it and start it again
|
||||
- Develop on you local development machine and deploy it on container
|
||||
|
||||
Build
|
||||
-----
|
||||
```
|
||||
docker build -t clearlinux/ciao-launcher .
|
||||
```
|
||||
|
||||
Or just pull it from Dockerhub
|
||||
------------------------------
|
||||
```
|
||||
docker pull clearlinux/ciao-launcher
|
||||
```
|
||||
|
||||
Start CIAO Launcher container
|
||||
-----------------------------
|
||||
### Run in daemon mode
|
||||
```
|
||||
docker run -it -d --name launcher --net=host --privileged -v /dev/kvm:/dev/kvm \
|
||||
-v /dev:/dev -v /var/run/docker.sock:/var/run/docker.sock \
|
||||
--cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun \
|
||||
-v `pwd`/certs/CAcert-localhost.pem:/etc/pki/ciao/CAcert-ciao-dev.pem \
|
||||
-v `pwd`/certs/cert-CNAgent-NetworkingAgent-localhost.pem:/etc/pki/ciao/cert-CNAgent-NetworkingAgent-ciao-dev.pem \
|
||||
-v $GOPATH/src/github.com/01org/ciao:/root/go/src/github.com/01org/ciao \
|
||||
ciao/launcher
|
||||
```
|
||||
|
||||
### Run on manual mode
|
||||
```
|
||||
docker run -it --name launcher --net=host --privileged -v /dev/kvm:/dev/kvm \
|
||||
-v /dev:/dev -v /var/run/docker.sock:/var/run/docker.sock \
|
||||
--cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun \
|
||||
-v `pwd`/certs/CAcert-localhost.pem:/etc/pki/ciao/CAcert-ciao-dev.pem \
|
||||
-v `pwd`/certs/cert-CNAgent-NetworkingAgent-localhost.pem:/etc/pki/ciao/cert-CNAgent-NetworkingAgent-ciao-dev.pem \
|
||||
-v $GOPATH/src/github.com/01org/ciao:/root/go/src/github.com/01org/ciao \
|
||||
ciao/launcher bash
|
||||
|
||||
# Inside container
|
||||
root@example.com # ls
|
||||
ciaorc go launcher.sh share
|
||||
|
||||
# Manual Start of Ciao Launcher
|
||||
root@example.com # ./launcher.sh
|
||||
```
|
||||
|
||||
Environment Variables
|
||||
---------------------
|
||||
|
||||
|
||||
Extra Build ARGs
|
||||
----------------
|
||||
- ``swupd_args`` Specifies [SWUPD](https://clearlinux.org/documentation/swupdate_how_to_run_the_updater.html) flags
|
||||
|
||||
Default build args in Docker are on: https://docs.docker.com/engine/reference/builder/#/arg
|
||||
@@ -0,0 +1,25 @@
|
||||
# Only listen to routers' LAN NIC. Doing so opens up tcp/udp port 53 to
|
||||
# localhost and udp port 67 to world:
|
||||
interface=macvlan0
|
||||
|
||||
listen-address=192.168.0.1
|
||||
|
||||
# dnsmasq will open tcp/udp port 53 and udp port 67 to world to help with
|
||||
# dynamic interfaces (assigning dynamic ips). Dnsmasq will discard world
|
||||
# requests to them, but the paranoid might like to close them and let the
|
||||
# kernel handle them:
|
||||
bind-interfaces
|
||||
|
||||
# Dynamic range of IPs to make available to LAN pc
|
||||
dhcp-range=192.168.0.50,192.168.0.100,12h
|
||||
|
||||
# If you’d like to have dnsmasq assign static IPs, bind the LAN computer's
|
||||
# NIC MAC address:
|
||||
|
||||
except-interface=lo
|
||||
|
||||
log-queries
|
||||
|
||||
log-dhcp
|
||||
|
||||
#dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.50
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/bin/bash
|
||||
#Defaults
|
||||
|
||||
set -x
|
||||
image="clear-8260-ciao-networking.img"
|
||||
certs_dir=$GOPATH/src/github.com/01org/ciao/networking/ciao-cnci-agent/scripts/certs
|
||||
cnci_agent=$GOPATH/bin/ciao-cnci-agent
|
||||
cnci_sysd=$GOPATH/src/github.com/01org/ciao/networking/ciao-cnci-agent/scripts/ciao-cnci-agent.service
|
||||
partition="2"
|
||||
download=0
|
||||
|
||||
usage="$(basename "$0") [--image clear_cnci_image_name] [-certs certificate_directory] [-agent cnci_agent_binary] [-script cnci_systemd_script] \n\n A simple script to create a CNCI Image from a clear cloud image. \n Defaults for any unspecified option are as follows \n\n --agent $cnci_agent \n --certs $certs_dir \n --image $image \n --script $cnci_sysd\n\n"
|
||||
|
||||
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
-a | --agent)
|
||||
cnci_agent="$2"
|
||||
shift 2
|
||||
;;
|
||||
-c | --certs)
|
||||
certs_dir="$2"
|
||||
shift 2
|
||||
;;
|
||||
-d | --download)
|
||||
download=1
|
||||
shift 1
|
||||
;;
|
||||
-h | --help)
|
||||
echo -e "$usage" >&2
|
||||
exit 0
|
||||
;;
|
||||
-i | --image)
|
||||
image="$2"
|
||||
shift 2
|
||||
;;
|
||||
-s | --script)
|
||||
cnci_sysd="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
set -o nounset
|
||||
|
||||
if [ $download -eq 1 ]
|
||||
then
|
||||
rm -f "$image"
|
||||
curl -O https://download.clearlinux.org/demos/ciao/"$image".xz
|
||||
unxz "$image".xz
|
||||
fi
|
||||
|
||||
echo -e "\nMounting image: $image"
|
||||
tmpdir=$(mktemp -d)
|
||||
#sudo modprobe nbd max_part=63
|
||||
#sudo qemu-nbd --format=raw -c /dev/nbd0 "$image"
|
||||
|
||||
#it can take some time for the device to get created
|
||||
retry=0
|
||||
loop=''
|
||||
until [ $retry -ge 3 ]
|
||||
do
|
||||
if [ "$loop" == "" ]; then
|
||||
loop=`sudo losetup -f --show -P $image`
|
||||
fi
|
||||
sudo mount ${loop}p$partition "$tmpdir" && break
|
||||
let retry=retry+1
|
||||
echo "Mount failed, retrying $retry"
|
||||
sleep 10
|
||||
done
|
||||
|
||||
if [ $retry -ge 3 ]
|
||||
then
|
||||
echo "Unable to mount CNCI Image"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "Cleaning up any artifacts"
|
||||
sudo rm -rf "$tmpdir"/var/lib/ciao
|
||||
|
||||
echo -e "Copying agent image"
|
||||
sudo cp "$cnci_agent" "$tmpdir"/usr/sbin/
|
||||
|
||||
echo -e "Copying agent systemd service script"
|
||||
sudo cp "$cnci_sysd" "$tmpdir"/usr/lib/systemd/system/
|
||||
|
||||
echo -e "Installing the service"
|
||||
sudo mkdir -p "$tmpdir"/etc/systemd/system/default.target.wants
|
||||
sudo rm -f "$tmpdir"/etc/systemd/system/default.target.wants/ciao-cnci-agent.service
|
||||
sudo chroot "$tmpdir" /bin/bash -c "sudo ln -s /usr/lib/systemd/system/ciao-cnci-agent.service /etc/systemd/system/default.target.wants/"
|
||||
|
||||
echo -e "Copying CA certificates"
|
||||
sudo mkdir -p "$tmpdir"/var/lib/ciao/
|
||||
sudo cp "$certs_dir"/CAcert-* "$tmpdir"/var/lib/ciao/CAcert-server-localhost.pem
|
||||
|
||||
echo -e "Copying CNCI Agent certificate"
|
||||
sudo cp "$certs_dir"/cert-CNCIAgent-* "$tmpdir"/var/lib/ciao/cert-client-localhost.pem
|
||||
|
||||
echo -e "Removing cloud-init traces"
|
||||
sudo rm -rf "$tmpdir"/var/lib/cloud
|
||||
|
||||
#Umount
|
||||
echo -e "Done! unmounting\n"
|
||||
sudo umount "$tmpdir"
|
||||
sudo losetup -d $loop
|
||||
sudo rm -rf "$tmpdir"
|
||||
exit 0
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
# Copy images
|
||||
mkdir -p /var/lib/ciao/images
|
||||
if [ ! "$(ls -A /var/lib/ciao/images)" ]; then
|
||||
cp -r /share/images/* /var/lib/ciao/images/
|
||||
fi
|
||||
|
||||
# compile the code before running it
|
||||
go install github.com/01org/ciao/...
|
||||
cp -f $GOBIN/* /usr/bin
|
||||
|
||||
# Starting Compute Service
|
||||
mkdir -p /var/lib/misc
|
||||
mkdir -p /var/run
|
||||
|
||||
killall -9 dnsmasq
|
||||
dnsmasq -C /etc/dnsmasq.conf
|
||||
|
||||
$GOBIN/ciao-launcher -logtostderr -v=3
|
||||
Reference in New Issue
Block a user