Skip to content

Commit 7d1d15c

Browse files
Merge pull request #32 from mfojtik/self-contained-incremental
Initial implementation of incremental build in self-contained ruby builder image
2 parents 188c855 + c1d164a commit 7d1d15c

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cd $HOME
4+
5+
exec tar -xzf -
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
cd $HOME
4+
5+
# List the files and directories you would like to archive.
6+
#
7+
exec tar -czf - {bundle,gems}

centos-ruby-builder/bin/start

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ source ${HOME}/etc/helpers
1111
# If the /tmp/src is empty, then print usage and exit.
1212
(dir_is_empty /tmp/src) && print_usage_and_exit
1313

14+
# Detect the presence of $stdin and restore the artifacts
15+
# To restore the artifacts, you have to run the builder as:
16+
#
17+
# docker run -v $(pwd):/tmp/src openshift/centos-ruby-builder < artifacts.tgz
18+
#
19+
if [ -p /dev/stdin ]; then
20+
echo "---> Restoring artifacts"
21+
cat | ${HOME}/bin/restore-artifacts
22+
fi
23+
1424
# Build the ruby application first
1525
#
1626
${HOME}/bin/prepare
1727

1828
# Replace this script with the application runner at the end of the build.
1929
#
20-
echo "---> Build successful. Commit this image with: docker commit ${HOSTNAME} ruby-app"
30+
echo "---> Build successful. Commit this image with: 'docker commit ${HOSTNAME} ruby-app'"
31+
2132
cp -f ${HOME}/bin/run ${HOME}/bin/start && exit

centos-ruby-builder/etc/helpers

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33

44
function print_usage_and_exit() {
55
echo
6-
echo "This image can build your Ruby source code."
7-
echo "To build from a git repo, run this in your checked out repo:"
6+
echo "This is the Ruby/Rails self-contained builder image."
7+
echo "You can use this to produce application images:"
88
echo
9-
echo " docker run -v \$(pwd):/tmp/src openshift/centos-ruby-builder"
9+
echo " $ docker run -v \$(pwd):/tmp/src openshift/centos-ruby-builder"
1010
echo
11-
echo "Options:"
11+
echo "You can also archive artifacts from the current application image:"
12+
echo
13+
echo " $ docker run --entrypoint='${HOME}/bin/save-artifacts' ruby-app > archive.tgz"
14+
echo
15+
echo "And restore the artifacts on the next build:"
16+
echo
17+
echo " $ docker run -v \$(pwd):/tmp/src openshift/centos-ruby-builder < archive.tgz"
18+
echo
19+
echo "Other options:"
1220
echo
1321
echo " --debug Drop to the shell instead of build."
1422
echo
15-
exit
23+
exit 0
1624
}

0 commit comments

Comments
 (0)