Permalink
Browse files

Add dist/build to simplify building various Docker images and getting…

… packages out of them.
  • Loading branch information...
aaron42net committed Mar 8, 2016
1 parent ca37663 commit d238f21eab9959eb8cc1f88bdf14ff04dc940cc6
View
@@ -2,3 +2,5 @@
.gitignore
fotomat
*~
*.rpm
*.dpkg
View
@@ -1,11 +1,6 @@
# Build Fotomat RPM for Debian jessie using Docker.
#
# Run:
# docker build -f Dockerfile.dpkg-jessie -t dienet/fotomat:dpkg-jessie .
# docker run --name fotomat-dpkg-jessie dienet/fotomat:dpkg-jessie /bin/true
# docker export fotomat-dpkg-jessie | tar --strip-components=7 -xvf - app/src/github.com/die-net/fotomat/pkg/dpkg/fotomat.deb
# docker rm fotomat-dpkg-jessie
# docker rmi dienet/fotomat:dpkg-jessie
# Run: dist/build dpkg-jessie
#
# And you'll end up with a fotomat*.dpkg in the current directory.
@@ -49,10 +44,10 @@ RUN \
(perl -ne '/FotomatVersion.*\b(\d+\.\d+\.\d+)/ and print "Version: ${1}-1\n"' cmd/fotomat/version.go; \
ldd /app/bin/fotomat | awk '($2=="=>"&&substr($3,1,11)!="/usr/local/"){print $3}' | \
xargs dpkg -S | cut -d: -f1 | sort -u | xargs echo "Depends:" | sed 's/ /, /g;s/:,/:/' \
) >> pkg/dpkg/fotomat/DEBIAN/control && \
install -d -m 755 pkg/dpkg/fotomat/usr/sbin/ && \
install -s -m 755 /app/bin/fotomat pkg/dpkg/fotomat/usr/sbin/ && \
fakeroot dpkg-deb --build pkg/dpkg/fotomat && \
) >> dist/dpkg/fotomat/DEBIAN/control && \
install -d -m 755 dist/dpkg/fotomat/usr/sbin/ && \
install -s -m 755 /app/bin/fotomat dist/dpkg/fotomat/usr/sbin/ && \
fakeroot dpkg-deb --build dist/dpkg/fotomat && \
# And remove almost everything else that we installed
apt-get remove -y fakeroot git automake build-essential libglib2.0-dev libjpeg-dev libpng12-dev \
View
@@ -1,11 +1,6 @@
# Build Fotomat RPM for Debian stretch using Docker.
#
# Run:
# docker build -f Dockerfile.dpkg-stretch -t dienet/fotomat:dpkg-stretch .
# docker run --name fotomat-dpkg-stretch dienet/fotomat:dpkg-stretch /bin/true
# docker export fotomat-dpkg-stretch | tar --strip-components=7 -xvf - app/src/github.com/die-net/fotomat/pkg/dpkg/fotomat.deb
# docker rm fotomat-dpkg-stretch
# docker rmi dienet/fotomat:dpkg-stretch
# Run: dist/build dpkg-stretch
#
# And you'll end up with a fotomat*.dpkg in the current directory.
@@ -49,10 +44,10 @@ RUN \
(perl -ne '/FotomatVersion.*\b(\d+\.\d+\.\d+)/ and print "Version: ${1}-1\n"' cmd/fotomat/version.go; \
ldd /app/bin/fotomat | awk '($2=="=>"&&substr($3,1,11)!="/usr/local/"){print $3}' | \
xargs dpkg -S | cut -d: -f1 | sort -u | xargs echo "Depends:" | sed 's/ /, /g;s/:,/:/' \
) >> pkg/dpkg/fotomat/DEBIAN/control && \
install -d -m 755 pkg/dpkg/fotomat/usr/sbin/ && \
install -s -m 755 /app/bin/fotomat pkg/dpkg/fotomat/usr/sbin/ && \
fakeroot dpkg-deb --build pkg/dpkg/fotomat && \
) >> dist/dpkg/fotomat/DEBIAN/control && \
install -d -m 755 dist/dpkg/fotomat/usr/sbin/ && \
install -s -m 755 /app/bin/fotomat dist/dpkg/fotomat/usr/sbin/ && \
fakeroot dpkg-deb --build dist/dpkg/fotomat && \
# And remove almost everything else that we installed
apt-get remove -y fakeroot git automake build-essential libglib2.0-dev libjpeg-dev libpng12-dev \
View
@@ -1,11 +1,6 @@
# Build Fotomat RPM for CentOS 6 using Docker.
#
# Run:
# docker build -f Dockerfile.rpm-centos6 -t dienet/fotomat:rpm-centos6 .
# docker run --name fotomat-rpm-centos6 dienet/fotomat:rpm-centos6 /bin/true
# docker export fotomat-rpm-centos6 | tar --strip-components=4 -xvf - root/rpmbuild/RPMS/*/fotomat*.rpm
# docker rm fotomat-rpm-centos6
# docker rmi dienet/fotomat:rpm-centos6
# Run: dist/build rpm-centos6
#
# And you'll end up with a fotomat*.rpm in the current directory.
@@ -51,8 +46,8 @@ RUN \
# Update specfile version and use it to build binary RPM.
perl -ne '/FotomatVersion.*\b(\d+\.\d+\.\d+)/ and print "$1\n"' /app/src/github.com/die-net/fotomat/cmd/fotomat/version.go | \
xargs -i{} perl -p -i~ -e 's/(^Version:\s+)\d+\.\d+\.\d+/${1}{}/' /app/src/github.com/die-net/fotomat/pkg/rpm/fotomat.spec && \
rpmbuild -bb /app/src/github.com/die-net/fotomat/pkg/rpm/fotomat.spec && \
xargs -i{} perl -p -i~ -e 's/(^Version:\s+)\d+\.\d+\.\d+/${1}{}/' /app/src/github.com/die-net/fotomat/dist/rpm/fotomat.spec && \
rpmbuild -bb /app/src/github.com/die-net/fotomat/dist/rpm/fotomat.spec && \
# Remove almost everything we've installed, leaving just binary RPM.
rm -rf /usr/local/go /usr/local/vips /app/pkg /app/bin && \
View
@@ -1,11 +1,6 @@
# Build Fotomat RPM for CentOS 7 using Docker.
#
# Run:
# docker build -f Dockerfile.rpm-centos7 -t dienet/fotomat:rpm-centos7 .
# docker run --name fotomat-rpm-centos7 dienet/fotomat:rpm-centos7 /bin/true
# docker export fotomat-rpm-centos7 | tar --strip-components=4 -xvf - root/rpmbuild/RPMS/*/fotomat*.rpm
# docker rm fotomat-rpm-centos7
# docker rmi dienet/fotomat:rpm-centos7
# Run: dist/build rpm-centos7
#
# And you'll end up with a fotomat*.rpm in the current directory.
@@ -51,8 +46,8 @@ RUN \
# Update specfile version and use it to build binary RPM.
perl -ne '/FotomatVersion.*\b(\d+\.\d+\.\d+)/ and print "$1\n"' /app/src/github.com/die-net/fotomat/cmd/fotomat/version.go | \
xargs -i{} perl -p -i~ -e 's/(^Version:\s+)\d+\.\d+\.\d+/${1}{}/' /app/src/github.com/die-net/fotomat/pkg/rpm/fotomat.spec && \
rpmbuild -bb /app/src/github.com/die-net/fotomat/pkg/rpm/fotomat.spec && \
xargs -i{} perl -p -i~ -e 's/(^Version:\s+)\d+\.\d+\.\d+/${1}{}/' /app/src/github.com/die-net/fotomat/dist/rpm/fotomat.spec && \
rpmbuild -bb /app/src/github.com/die-net/fotomat/dist/rpm/fotomat.spec && \
# Remove almost everything we've installed, leaving just binary RPM.
rm -rf /usr/local/go /usr/local/vips /app/pkg /app/bin && \
View
@@ -8,7 +8,7 @@ import (
const (
// Updated by git-hooks/pre-commit
FotomatVersion = "2.0.146"
FotomatVersion = "2.2.147"
)
var (
View
@@ -0,0 +1,62 @@
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
cd $( dirname $0 )/..
version=$( perl -ne '/FotomatVersion.*\b(\d+\.\d+\.\d+)/ and print "${1}-1"' cmd/fotomat/version.go )
build() {
local tag="$1"
local path=""
local final=""
if [ ! -f Dockerfile.$tag ]; then
echo "Dockerfile.$tag doesn't exist!"
return
fi
case "$tag" in
dpkg-*)
path="app/src/github.com/die-net/fotomat/dist/dpkg/fotomat.deb"
final="fotomat-${version}.${tag/dpkg-/}.amd64.deb"
;;
rpm-*)
path="root/rpmbuild/RPMS/*/fotomat*.rpm"
;;
*)
echo "Don't understand how to parse tag $tag"
exit 1
;;
esac
local slashes=$(( 0 + $( echo "$path" | tr -cd / | wc -c ) ))
docker build -f Dockerfile.$tag -t dienet/fotomat:$tag .
docker rm fotomat-$tag || true
docker run --name fotomat-$tag dienet/fotomat:$tag /bin/true
docker export fotomat-$tag | tar --strip-components=$slashes -xvf - "$path" || true
docker rm fotomat-$tag
docker rmi dienet/fotomat:$tag
if [ ! -z "$final" ]; then
mv "$( basename "$path" )" "$final"
fi
}
if [ $# -eq 0 ]; then
echo "Usage: $0 <tag> [<tag> ...] - Build one or more package tags via Docker"
echo " $0 all - Build all available tags"
exit 1
fi
if [ "$1" = "all" ]; then
ls -1 Dockerfile.dpkg-* Dockerfile.rpm-* | while read file; do
tag=${file/Dockerfile./}
build "$tag"
done
else
for tag in "$@"; do
build "$tag"
done
fi
File renamed without changes.
File renamed without changes.

0 comments on commit d238f21

Please sign in to comment.