Skip to content

Commit

Permalink
Option for make-base-vm to create docker image
Browse files Browse the repository at this point in the history
make-base-vm can be run with --docker to create a dockerfile and
docker image for the specified arch and suite.
  • Loading branch information
achow101 committed May 31, 2018
1 parent 8f36257 commit 1ca59fd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bin/make-base-vm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARCH=amd64
MIRROR_BASE=http://${MIRROR_HOST:-127.0.0.1}:3142
LXC=0
VBOX=0
DOCKER=0

usage() {
echo "Usage: ${0##*/} [OPTION]..."
Expand All @@ -19,6 +20,7 @@ usage() {
--arch A build architecture A (e.g. i386) instead of amd64
--lxc use lxc instead of kvm
--vbox use VirtualBox instead of kvm
--docker use docker instead of kvm
The MIRROR_HOST environment variable can be used to change the
apt-cacher host. It should be something that both the host and the
Expand Down Expand Up @@ -70,6 +72,10 @@ if [ $# != 0 ] ; then
VBOX=1
shift 1
;;
--docker)
DOCKER=1
shift 1
;;
--*)
echo "unrecognized option $1"
exit 1
Expand Down Expand Up @@ -153,6 +159,32 @@ fi
# Remove cron to work around vmbuilder issue when umounting /dev on target
removepkg=cron

if [ $DOCKER = "1" ]; then

addpkg=`echo $addpkg | tr ',' ' '`

mkdir -p docker
cd docker

# Generate the dockerfile
cat << EOF > $OUT.Dockerfile
FROM $DISTRO:$SUITE
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get --no-install-recommends -y install $addpkg
RUN useradd -ms /bin/bash -U $DISTRO
USER $DISTRO:$DISTRO
WORKDIR /home/$DISTRO
CMD ["sleep", "infinity"]
EOF

docker build --pull -f $OUT.Dockerfile -t $OUT .

exit 0
fi

if [ $VBOX = "1" ]; then
NAME="$SUITE-$ARCH"
if ! vagrant status | grep "$NAME" | grep "not created" > /dev/null; then
Expand Down

0 comments on commit 1ca59fd

Please sign in to comment.