Add a "slim" variant. Fixes #2

This commit is contained in:
Olaf Meeuwissen 2017-10-22 16:01:37 +09:00
parent e0e4d09ed4
commit f0643a5fb8
5 changed files with 124 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/rootfs /rootfs
/rootfs-slim

View File

@ -39,3 +39,32 @@ if test $SUITE = stable; then
docker tag $IMAGE:$SUITE $IMAGE docker tag $IMAGE:$SUITE $IMAGE
docker push $IMAGE docker push $IMAGE
fi fi
docker run --rm \
--cap-add SYS_ADMIN \
--volume $PWD:/devuan \
--workdir /devuan \
$IMAGE ./trim.sh $SUITE $ROOTFS
IMAGE=$CI_REGISTRY_IMAGE/slim
STAMP=$(date +%F)
cat > Dockerfile <<EOF
FROM scratch
ADD $ROOTFS-slim.tar.gz /
CMD ["bash"]
EOF
docker build -t $IMAGE:$STAMP .
ALIAS=$(docker run --rm $IMAGE:$STAMP cat /etc/devuan_version)
docker push $IMAGE:$STAMP
docker tag $IMAGE:$STAMP $IMAGE:$ALIAS
docker push $IMAGE:$ALIAS
docker tag $IMAGE:$ALIAS $IMAGE:$SUITE
docker push $IMAGE:$SUITE
if test $SUITE = stable; then
docker tag $IMAGE:$SUITE $IMAGE
docker push $IMAGE
fi

View File

@ -0,0 +1,23 @@
#!/bin/sh -eu
# tweak-apt-config -- for use in a Docker image
# Copyright (C) 2017 Olaf Meeuwissen
#
# License: GPL-3.0+
DIR=/
ETC=etc/apt
PARTS=apt.conf.d
eval $(apt-config shell DIR Dir)
eval $(apt-config shell ETC Dir::Etc)
eval $(apt-config shell PARTS Dir::Etc::Parts)
cfg=$DIR$ETC$PARTS
cat > $cfg/docker-recommends <<EOF
APT::Install-Recommends "false";
APT::AutoRemove::RecommendsImportant "false";
EOF
chmod 0644 $cfg/docker-recommends
rm $0

View File

@ -0,0 +1,37 @@
#!/bin/sh -eu
# tweak-dpkg-config -- for use in a Docker image
# Copyright (C) 2017 Olaf Meeuwissen
#
# License: GPL-3.0+
cfg=/etc/dpkg/dpkg.cfg.d
cat > $cfg/docker-excludes <<EOF
path-exclude=/usr/share/doc/*
EOF
chmod 0644 $cfg/docker-excludes
cat > $cfg/docker-includes <<EOF
path-include=/usr/share/doc/*/copyright
EOF
chmod 0644 $cfg/docker-includes
# Retro-actively apply the above on what's already installed.
find /usr/share/doc/* -type f ! -name copyright -delete
find /usr/share/doc/* -empty -delete
for dir in \
/usr/share/groff \
/usr/share/info \
/usr/share/linda \
/usr/share/lintian \
/usr/share/locale \
/usr/share/man \
; do
cat >> $cfg/docker-excludes <<EOF
path-exclude=$dir/*
EOF
find $dir/* -delete
done
rm $0

34
trim.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh -eu
# trim.sh -- some flab of a Devuan base image
# Copyright (C) 2017 Olaf Meeuwissen
#
# License: GPL-3.0+
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND
suite=$1
rootfs=$2
cp -al $rootfs $rootfs-slim
rootfs=$rootfs-slim
mount -t devpts devpts $rootfs/dev/pts
bindir=usr/local/bin
install -m 0755 -o root -g root scripts-slim/* $rootfs/$bindir
for script in $(ls $rootfs/$bindir); do
echo "+ /$bindir/$script"
chroot $rootfs /$bindir/$script $suite
done
chroot $rootfs apt-get --purge autoremove -q -y
chroot $rootfs /$bindir/docker-apt-clean $suite
umount $rootfs/dev/pts
tar -caf $rootfs.tar.gz \
--directory $rootfs \
--exclude './dev/**' \
--numeric-owner \
--transform 's,^\./,,' .