Docker image creation script. Makefile updated to let users use 'sudo make docker-image' and 'sudo make install-docker-image' to build and create docker image of photon. Currently it uses photon bintray repo instead of using local rpms to create the image. Fix pullsources.py bug that breaks in parallel download. Fix some spec files.
This commit is contained in:
parent
e97e4fe10d
commit
16934d5c41
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!stage/photon-rootfs.tar.bz2
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
FROM scratch
|
||||
MAINTAINER tliaqat@vmware.com
|
||||
|
||||
ADD rootfs.tar.bz2 /
|
||||
ADD stage/photon-rootfs.tar.bz2 /
|
||||
|
||||
VOLUME /var/lib/docker
|
||||
|
15
Makefile
15
Makefile
|
@ -44,7 +44,7 @@ clean-install clean-chroot
|
|||
|
||||
PARALLEL=False
|
||||
|
||||
all: iso micro-iso minimal-iso
|
||||
all: iso micro-iso minimal-iso docker-image
|
||||
|
||||
micro: micro-iso
|
||||
|
||||
|
@ -163,6 +163,19 @@ $(PHOTON_STAGE):
|
|||
@echo "Building LOGS folder..."
|
||||
@test -d $(PHOTON_LOGS_DIR) || $(MKDIR) -p $(PHOTON_LOGS_DIR)
|
||||
|
||||
docker-image:
|
||||
sudo docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--privileged \
|
||||
--net=host \
|
||||
-v `pwd`:/workspace \
|
||||
toliaqat/photon-dev \
|
||||
./support/dockerfiles/photon/make-docker-image.sh /workspace
|
||||
|
||||
install-docker-image: docker-image
|
||||
sudo docker build -t photon:base .
|
||||
|
||||
clean: clean-install clean-chroot
|
||||
@echo "Deleting Photon ISO..."
|
||||
@$(RM) -f $(PHOTON_STAGE)/photon.iso
|
||||
|
|
|
@ -24,7 +24,7 @@ The Apache Portable Runtime Utility Library.
|
|||
%setup -q
|
||||
%build
|
||||
%configure --with-apr=%{_prefix} \
|
||||
--includedir=%{_includedir}/apr-%{apuver} \
|
||||
--includedir=%{_includedir}/apr-%{version} \
|
||||
--with-ldap --without-gdbm \
|
||||
--with-sqlite3 --with-pgsql \
|
||||
--without-sqlite2 \
|
||||
|
@ -47,10 +47,12 @@ rm -rf $RPM_BUILD_ROOT
|
|||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
/usr/lib/*
|
||||
/usr/bin/*
|
||||
/usr/include/*
|
||||
%{_libdir}/*
|
||||
%{_bindir}/*
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Jul 01 2015 Touseef Liaqat <tliaqat@vmware.com> 1.5.2-2
|
||||
- Fix tags and paths.
|
||||
* Wed May 20 2015 Touseef Liaqat <tliaqat@vmware.com> 1.5.2-1
|
||||
- Initial build. First version
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Summary: The Apache Portable Runtime
|
||||
Name: apr
|
||||
Version: 1.5.2
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: Apache License 2.0
|
||||
URL: https://apr.apache.org/
|
||||
Group: System Environment/Libraries
|
||||
|
@ -15,8 +15,8 @@ The Apache Portable Runtime.
|
|||
%setup -q
|
||||
%build
|
||||
./configure --prefix=/usr \
|
||||
--includedir=%{_includedir}/apr-%{aprver} \
|
||||
--with-installbuilddir=%{_libdir}/apr/build-%{aprver} \
|
||||
--includedir=%{_includedir}/apr-%{version} \
|
||||
--with-installbuilddir=%{_libdir}/apr/build-%{version} \
|
||||
--with-devrandom=/dev/urandom \
|
||||
CC=gcc CXX=g++
|
||||
|
||||
|
@ -29,10 +29,12 @@ make DESTDIR=%{buildroot} install
|
|||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
/usr/lib/*
|
||||
/usr/bin/*
|
||||
/usr/include/*
|
||||
%{_libdir}/*
|
||||
%{_bindir}/*
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Jul 01 2015 Touseef Liaqat <tliaqat@vmware.com> 1.5.2-2
|
||||
- Fix tags and paths.
|
||||
* Wed May 20 2015 Touseef Liaqat <tliaqat@vmware.com> 1.5.2-1
|
||||
- Initial build. First version
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Script to create new Photon Docker image."
|
||||
echo "Usage: $0 <path to workspace> <installation type>"
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Script to create new photon base docker image."
|
||||
echo "Usage: $0 <path to workspace>"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
@ -10,35 +10,67 @@ set -e
|
|||
set -x
|
||||
|
||||
PROGRAM=$0
|
||||
ROOT=$1
|
||||
TYPE=$2
|
||||
IN_CONTAINER=$3
|
||||
WORKSPACE_DIR=$1
|
||||
RPMS_DIR=$WORKSPACE_DIR/stage/RPMS
|
||||
TEMP_CHROOT=$(pwd)/temp_chroot
|
||||
|
||||
ROOTFS_TAR_FILENAME=rootfs.tar.bz2
|
||||
INSTALLER_DIR=/workspace/photon/installer
|
||||
PACKAGE_BUILDER_DIR=/workspace/photon/support/package-builder
|
||||
DOCKERFILES_DIR=/workspace/photon/support/dockerfiles/photon/
|
||||
ROOTFS_TAR_FILENAME=photon-rootfs.tar.bz2
|
||||
STAGE_DIR=$WORKSPACE_DIR/stage
|
||||
|
||||
if [ -z "$IN_CONTAINER" ]
|
||||
then
|
||||
rm -f $ROOTFS_TAR_FILENAME
|
||||
docker run -it --privileged --rm -v $ROOT:/workspace toliaqat/ubuntu-dev bash /workspace/photon/support/dockerfiles/photon/${PROGRAM} $ROOT $TYPE "In Container" && \
|
||||
[ -e "$ROOTFS_TAR_FILENAME" ] && docker build -t photon:$TYPE .
|
||||
else
|
||||
|
||||
cd $INSTALLER_DIR && \
|
||||
cp sample_config.json docker_image_config.json && \
|
||||
sed -i -e "s/minimal/$TYPE/" docker_image_config.json && \
|
||||
./photonInstaller.py -f -w /mnt/photon-root docker_image_config.json && \
|
||||
rm docker_image_config.json
|
||||
cd $PACKAGE_BUILDER_DIR && \
|
||||
./umount-build-root.sh /mnt/photon-root && \
|
||||
cd /mnt/photon-root && \
|
||||
rm -rf tools/
|
||||
rm -rf usr/src/
|
||||
rm -rf boot/
|
||||
rm -rf lib/modules/
|
||||
tar cpjf /$ROOTFS_TAR_FILENAME . && \
|
||||
cp /$ROOTFS_TAR_FILENAME $DOCKERFILES_DIR
|
||||
fi
|
||||
|
||||
sudo createrepo $RPMS_DIR
|
||||
|
||||
cat > yum.conf <<- "EOF"
|
||||
|
||||
[main]
|
||||
cachedir=$(pwd)/temp_chroot/var/cache/yum
|
||||
keepcache=1
|
||||
debuglevel=2
|
||||
logfile=$(pwd)/temp_chroot/var/log/yum.log
|
||||
exactarch=1
|
||||
obsoletes=1
|
||||
|
||||
[photon]
|
||||
name=VMware Photon Linux 1.0(x86_64)
|
||||
baseurl=https://dl.bintray.com/vmware/photon_release_1.0_x86_64
|
||||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
skip_if_unavailable=True
|
||||
|
||||
EOF
|
||||
|
||||
rm -rf $TEMP_CHROOT
|
||||
mkdir $TEMP_CHROOT
|
||||
|
||||
# use host's yum to install in chroot
|
||||
yum -c yum.conf --installroot=$TEMP_CHROOT install -y filesystem glibc
|
||||
yum -c yum.conf --installroot=$TEMP_CHROOT install -y bash tdnf coreutils photon-release
|
||||
yum -c yum.conf clean all
|
||||
cp /etc/resolv.conf $TEMP_CHROOT/etc/
|
||||
|
||||
# reinstalling inside to make sure rpmdb is created for tdnf.
|
||||
# TODO find better solution.
|
||||
chroot $TEMP_CHROOT bash -c \
|
||||
"tdnf install -y filesystem; \
|
||||
tdnf install -y glibc ; \
|
||||
tdnf install -y bash ; \
|
||||
tdnf install -y coreutils ; \
|
||||
tdnf install -y tdnf ; \
|
||||
tdnf install -y photon-release; \
|
||||
rpm -e --nodeps perl"
|
||||
|
||||
cd $TEMP_CHROOT
|
||||
# cleanup anything not needed inside rootfs
|
||||
rm -rf usr/src/
|
||||
rm -rf home/*
|
||||
rm -rf var/lib/yum/*
|
||||
rm -rf /var/log/*
|
||||
tar cpjf ../$ROOTFS_TAR_FILENAME .
|
||||
mv ../$ROOTFS_TAR_FILENAME $STAGE_DIR
|
||||
cd ..
|
||||
|
||||
# cleanup
|
||||
rm -rf $TEMP_CHROOT
|
||||
rm yum.conf
|
||||
|
||||
|
|
|
@ -46,17 +46,6 @@ class pullSources:
|
|||
f.close()
|
||||
return sha1.hexdigest()
|
||||
|
||||
def downloadExistingFilePrompt(self, filename):
|
||||
yes = ['yes', 'y']
|
||||
no = ['no', 'n']
|
||||
while True:
|
||||
prompt = "Found a different local copy of {0}. Do you want to replace it? [y/n]:".format(filename)
|
||||
answer = raw_input(prompt).lower()
|
||||
if answer in yes:
|
||||
return True
|
||||
elif answer in no:
|
||||
return False
|
||||
|
||||
def downloadFile(self, filename, file_path):
|
||||
print '%s: Downloading %s...' % (str(datetime.datetime.today()), filename)
|
||||
|
||||
|
@ -112,8 +101,7 @@ class pullSources:
|
|||
self.downloadFileHelper(package_name, package_path, package_sha1)
|
||||
|
||||
elif package_sha1 != self.getFileHash(package_path):
|
||||
if self.downloadExistingFilePrompt(package_name):
|
||||
self.downloadFileHelper(package_name, package_path, package_sha1)
|
||||
self.downloadFileHelper(package_name, package_path, package_sha1)
|
||||
|
||||
def _pickle(method):
|
||||
if method.im_self is None:
|
||||
|
|
Loading…
Reference in New Issue