Commit 37c5e50b authored by David Johnson's avatar David Johnson

Add Ubuntu14 Docker container support.

parent 39946ee4
##
## Much of this is taken from
## https://github.com/tianon/dockerfiles/blob/master/sbin-init/ubuntu/upstart/14.1#0/Dockerfile
## . Reworked to use fewer RUN statements! Also removed a bit of ssh
## configuration that we handle by default in Emulabization, and removed
## the static root passwd.
##
# Generate some fake events and trigger runlevel 3.
ADD init-fake.conf /etc/init/fake-container-events.conf
# let Upstart know it's in a container
ENV container docker
# undo some leet hax of the base image
# generate a nice UTF-8 locale for our use
# remove some pointless services
# small fix for SSH in 13.10 (that's harmless everywhere else)
RUN rm /usr/sbin/policy-rc.d; \
rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl ; \
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 ; \
/usr/sbin/update-rc.d -f ondemand remove; \
for f in \
/etc/init/u*.conf \
/etc/init/mounted-dev.conf \
/etc/init/mounted-proc.conf \
/etc/init/mounted-run.conf \
/etc/init/mounted-tmp.conf \
/etc/init/mounted-var.conf \
/etc/init/hostname.conf \
/etc/init/networking.conf \
/etc/init/tty*.conf \
/etc/init/plymouth*.conf \
/etc/init/hwclock*.conf \
/etc/init/module*.conf\
; do \
dpkg-divert --local --rename --add "$f"; \
done; \
echo '# /lib/init/fstab: cleared out for bare-bones Docker' >/lib/init/fstab ; \
sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
# prepare for takeoff
CMD ["/sbin/init"]
{
"HostConfig" : {
"SecurityOpt" : [ "seccomp=unconfined" ],
"Tmpfs" : {
"/run" : "",
"/run/lock":""
}
}
}
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
openssh-server rsyslog logrotate iproute2 iputils-ping net-tools sudo
## Permissions on these should be the same as the host, so preserve them.
#cp -p /tmp/src/ssh-host-keys/ssh_host* /etc/ssh/
## Install default SSH key for root and app.
mkdir -p /root/.ssh
chmod 700 /root/.ssh
chown root:root /root/.ssh
echo console >> /etc/securetty
exit 0
#!/bin/sh
#
# We expect several environment vars to be set:
# EMULABSRC -- points to the source tree, may be read-only
# PUBSUBSRC -- points to the pubsub source tree, may be read-only
# DESTDIR -- points to an empty read-write volume from the host
# (if unset, this will just install the clientside into the container root)
#
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
git ca-certificates \
gcc make libc-dev byacc libtool libssl-dev 'g++' \
sudo python python-dev libpcap-dev libboost-dev wget patch flex ntp
if [ -z "$EMULABSRC" ]; then
echo "WARNING: missing EMULABSRC environment variable pointer to src; cloning!"
export EMULABSRC=/tmp/emulab-devel
cd /tmp
git clone https://gitlab.flux.utah.edu/emulab/emulab-devel $EMULABSRC
[ ! $? -eq 0 ] && exit 1
fi
if [ -z "$PUBSUBSRC" ]; then
echo "WARNING: missing PUBSUBSRC environment variable pointer to src; cloning!"
export PUBSUBSRC=/tmp/pubsub
cd /tmp
git clone https://gitlab.flux.utah.edu/emulab/pubsub $PUBSUBSRC
[ ! $? -eq 0 ] && exit 1
fi
#export CFLAGS="-static"
mkdir -p /tmp/pubsub.obj
cd /tmp/pubsub.obj
cp -pRv $PUBSUBSRC/* /tmp/pubsub.obj
./configure && make && make install
[ ! $? -eq 0 ] && exit 1
cd /tmp
rm -rf /tmp/pubsub.obj
#
# If we installed to a DESTDIR, well, we're going to need pubsub dropped
# into real root here too, for the clientside build. So copy it in if
# so.
#
if [ -n "$DESTDIR" ]; then
cp -pRv $DESTDIR/* /
fi
echo /usr/local/lib > /etc/ld.so.conf.d/pubsub.conf
ldconfig
mkdir -p /tmp/emulab.obj
cd /tmp/emulab.obj
export NONTP=1
$EMULABSRC/clientside/configure --with-TBDEFS=$EMULABSRC/defs-utahclient \
&& make client && make client-install \
&& make -C tmcc/linux docker-guest-install
[ ! $? -eq 0 ] && exit 1
cd /tmp
rm -rf /tmp/emulab.obj
#
# Create these traditional NFS mountpoints now. Scripts get unhappy
# about them if they're not there.
#
mkdir -p $DESTDIR/users $DESTDIR/proj $DESTDIR/groups $DESTDIR/share
exit 0
#!/bin/sh
#
# Builds the artifacts required for the core option (that is, the clientside).
#
if [ -n "$DESTDIR" ]; then
export DESTDIR="$DESTDIR/emulab-client-install"
mkdir -p $DESTDIR
fi
ubuntu/prepare.sh && ubuntu14/buildenv.sh && ubuntu/cleanup.sh
exit $?
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
ca-certificates sudo python wget patch nano file \
perl perl-modules libwww-perl psmisc tcsh zsh ksh rsync
#
# Create these traditional NFS mountpoints now. Scripts get unhappy
# about them if they're not there.
#
mkdir -p /users /proj /groups /share
exit 0
#!/bin/sh
mkdir -p /var/lock/subsys
echo -n 'testbed config: '
/usr/local/etc/emulab/rc/rc.testbed
if [ ! $? -eq 0 ]; then
echo "Failed to start /usr/local/etc/emulab/rc/rc.testbed: $?"
#touch /etc/service/testbed/down
exit $?
fi
touch /var/lock/subsys/testbed
#
# runit expects the run file to continue execution until death.
#
while [ 1 -eq 1 ]; do
sleep 60
done
exit 0
Defaults !env_reset
Defaults !mail_badpass
%admin ALL=(ALL) NOPASSWD: ALL
%root ALL=(ALL) NOPASSWD: ALL
#!/bin/sh
export container=docker
#exec /lib/systemd/systemd --log-target=journal 3>&1
exec /sbin/init
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
iproute2 bridge-utils vlan less
#!/bin/sh
#
# Builds the artifacts required for runit on Ubuntu. Our version is
# customized.
#
set -x
export DEBIAN_FRONTEND=noninteractive
if [ -n "$DESTDIR" ]; then
export DESTDIR="$DESTDIR/runit"
mkdir -p $DESTDIR
fi
DIRNAME=`pwd`
$DIRNAME/ubuntu/prepare.sh
apt-get install -y --no-install-suggests --no-install-recommends \
build-essential dpkg-dev wget
cd /tmp
if [ -z "$RUNITSRC" ]; then
apt-get install -y --no-install-suggests --no-install-recommends \
git ca-certificates
git clone https://gitlab.flux.utah.edu/emulab/runit runit
else
mkdir -p runit
cp -pR $RUNITSRC/* runit
fi
cd runit/
if [ ! -f runit-2.1.2.tar.gz ]; then
wget http://www.emulab.net/downloads/docker/runit-2.1.2.tar.gz
if [ ! $? -eq 0 ]; then
wget http://smarden.org/runit/runit-2.1.2.tar.gz
fi
fi
if [ -d runit-2.1.2 ]; then
rm -rf runit-2.1.2
fi
tar -xzf runit-2.1.2.tar.gz --strip-components=1
dpkg-buildpackage -uc -us
cd ..
cp -p *.deb $DESTDIR/
rm -rf runit *.deb *.dsc
$DIRNAME/ubuntu/cleanup.sh
exit 0
#!/bin/sh
#
# Install and configure runit, including our ssh/syslog unit files. We
# have a custom version of runit that was built in runit-artifacts.sh,
# so install that one.
#
set -x
export DEBIAN_FRONTEND=noninteractive
#export LANGUAGE=en_US:en
#export LC_ALL=en_US.UTF-8
#export LANG=en_US.UTF-8
#export LC_CTYPE=en_US.UTF-8
dpkg -i /tmp/runit_*.deb
apt-get install -y --no-install-suggests --no-install-recommends -f
#language-pack-en
## See https://github.com/dotcloud/docker/issues/1024
#dpkg-divert --local --rename --add /sbin/initctl
#ln -sf /bin/true /sbin/initctl
## https://bugs.launchpad.net/launchpad/+bug/974584
#dpkg-divert --local --rename --add /usr/bin/ischroot
#ln -sf /bin/true /usr/bin/ischroot
#locale-gen $LANG
#update-locale LANG=$LANG
# Configure runit services.
#mkdir -p /etc/service/sshd
#touch /etc/service/sshd/down
#mkdir -p /etc/service/rsyslog
#touch /etc/service/rsyslog/down
#mkdir -p /etc/service/testbed
#touch /etc/service/testbed/down
#mkdir -p /etc/service/tbprepare
#touch /etc/service/testbed/up
exit 0
#!/bin/sh
set -x
rm /usr/sbin/policy-rc.d
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
/usr/sbin/update-rc.d -f ondemand remove
for f in \
/etc/init/u*.conf \
/etc/init/mounted-dev.conf \
/etc/init/mounted-proc.conf \
/etc/init/mounted-run.conf \
/etc/init/mounted-tmp.conf \
/etc/init/mounted-var.conf \
/etc/init/hostname.conf \
/etc/init/networking.conf \
/etc/init/tty*.conf \
/etc/init/plymouth*.conf \
/etc/init/hwclock*.conf \
/etc/init/module*.conf ; do
dpkg-divert --local --rename --add "$f"
done
echo '# /lib/init/fstab: cleared out for bare-bones Docker' >/lib/init/fstab
sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment