Browse Source

Option for make-base-vm to create docker image

make-base-vm can be run with --docker to create a dockerfile and
docker image for the specified arch and suite.
pull/181/head
Andrew Chow 2 years ago
parent
commit
1ca59fd8fb
1 changed files with 32 additions and 0 deletions
  1. 32
    0
      bin/make-base-vm

+ 32
- 0
bin/make-base-vm View File

@@ -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]..."
@@ -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
@@ -70,6 +72,10 @@ if [ $# != 0 ] ; then
VBOX=1
shift 1
;;
--docker)
DOCKER=1
shift 1
;;
--*)
echo "unrecognized option $1"
exit 1
@@ -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

Loading…
Cancel
Save