forked from vmware/photon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Touseef Liaqat
committed
Jul 1, 2015
1 parent
e97e4fe
commit 16934d5
Showing
7 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!stage/photon-rootfs.tar.bz2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
FROM scratch | ||
MAINTAINER [email protected] | ||
|
||
ADD rootfs.tar.bz2 / | ||
ADD stage/photon-rootfs.tar.bz2 / | ||
|
||
VOLUME /var/lib/docker | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> 1.5.2-2 | ||
- Fix tags and paths. | ||
* Wed May 20 2015 Touseef Liaqat <[email protected]> 1.5.2-1 | ||
- Initial build. First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> 1.5.2-2 | ||
- Fix tags and paths. | ||
* Wed May 20 2015 Touseef Liaqat <[email protected]> 1.5.2-1 | ||
- Initial build. First version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,76 @@ | ||
#!/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 | ||
|
||
set -e | ||
set -x | ||
|
||
PROGRAM=$0 | ||
ROOT=$1 | ||
TYPE=$2 | ||
IN_CONTAINER=$3 | ||
|
||
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/ | ||
|
||
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 | ||
WORKSPACE_DIR=$1 | ||
RPMS_DIR=$WORKSPACE_DIR/stage/RPMS | ||
TEMP_CHROOT=$(pwd)/temp_chroot | ||
|
||
ROOTFS_TAR_FILENAME=photon-rootfs.tar.bz2 | ||
STAGE_DIR=$WORKSPACE_DIR/stage | ||
|
||
|
||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters