Skip to content

Commit

Permalink
Merge feature/reduce-size
Browse files Browse the repository at this point in the history
* Improve generate-dockerimage-info
* Add baselayout for typo3-solr
* Implement Arch Linux support for baselayout
* Remove lsb-release
* Fix dependency detection for latest images
* Remove logrotate
* Improve bootstrap
  * Add transparent wrapper for apt-add-repository (automatic installation & deinstallation)
  * Add prefetched apt repository lists (cleanup in docker-image-cleanup; reduce load on debian and ubuntu repositories)
* Reduze size for bootstrap
  * Add docker image cleanup script
  * Add static distribution information collection (for testsuite)
  • Loading branch information
mblaschke committed Mar 26, 2017
1 parent d4886ad commit 0146d00
Show file tree
Hide file tree
Showing 429 changed files with 1,365 additions and 1,278 deletions.
8 changes: 8 additions & 0 deletions baselayout/usr/local/bin/apt-add-repository
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

apt-install software-properties-common
add-apt-repository $@
apt-get purge -y -f software-properties-common
20 changes: 13 additions & 7 deletions baselayout/usr/local/bin/apt-install
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true

export DEBIAN_FRONTEND=noninteractive

# Update apt cache
apt-get update
if [[ -f "/tmp/.apt-update" ]]; then
echo "Detected prefetched 'apt-get update'"
# Install packages
apt-get install -y -f --no-install-recommends $*
else
# Update apt cache
apt-get update

# Install packages
apt-get install -y -f --no-install-recommends $*
# Install packages
apt-get install -y -f --no-install-recommends $*

# Clear files (reduce snapshot size)
rm -rf /var/lib/apt/lists/*
apt-get clean -y
# Clear files (reduce snapshot size)
rm -rf /var/lib/apt/lists/*
apt-get clean -y
fi
9 changes: 9 additions & 0 deletions baselayout/usr/local/bin/apt-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

apt-get update
touch /tmp/.apt-update
20 changes: 13 additions & 7 deletions baselayout/usr/local/bin/apt-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true

export DEBIAN_FRONTEND=noninteractive

# Update apt cache
apt-get update
if [[ -f "/tmp/.apt-update" ]]; then
echo "Detected prefetched 'apt-get update'"
# Update packages
apt-get dist-upgrade -y -f
else
# Update apt cache
apt-get update

# Install packages
apt-get dist-upgrade -y -f
# Update packages
apt-get dist-upgrade -y -f

# Clear files (reduce snapshot size)
rm -rf /var/lib/apt/lists/*
apt-get clean -y
# Clear files (reduce snapshot size)
rm -rf /var/lib/apt/lists/*
apt-get clean -y
fi
35 changes: 35 additions & 0 deletions baselayout/usr/local/bin/docker-image-cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

LSB_FAMILY=$(cat /etc/dockerimage_distribution_family)

case "$LSB_FAMILY" in
Debian)
rm -f /tmp/.apt-update
apt-get autoremove -y -f
apt-get clean -y
rm -rf /var/lib/apt/lists/*
;;

RedHat)
yum autoremove --assumeyes
yum clean all
;;

Alpine)
find /var/lib/apk/ -mindepth 1 -delete
;;

Arch)
pacman -Sc
;;

*)
echo "ERROR: Distribution $LSB_FAMILY not supported"
exit 1
;;
esac

find /tmp/ /var/log/ -mindepth 1 -delete
95 changes: 95 additions & 0 deletions baselayout/usr/local/bin/generate-dockerimage-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/sh

set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

LSB_FAMILY=""

#############################
# Distribution detection
#############################

if [ -x "/usr/bin/apt-get" ]; then
# Debian family
LSB_FAMILY="Debian"

elif [ -x "/bin/yum" ]; then
# RedHat family
LSB_FAMILY="RedHat"

elif [ -x "/sbin/apk" ]; then
# Alpine family
LSB_FAMILY="Alpine"

elif [ -f "/etc/arch-release" ]; then
# Alpine family
LSB_FAMILY="Arch"

else
# Unknown
echo "ERROR: Distribution detection failed"
exit 1
fi

#############################
# Install
#############################

case "$LSB_FAMILY" in
Debian)
apt-install lsb-release
;;

RedHat)
yum-install redhat-lsb-core
;;
esac

#############################
# Set distribution information
#############################

echo "Detected $LSB_FAMILY"
echo "$LSB_FAMILY" > /etc/dockerimage_distribution_family
echo "$LSB_FAMILY" > /etc/dockerimage_distribution

# Create all files
touch /etc/dockerimage_distribution_version
touch /etc/dockerimage_lsb
touch /etc/dockerimage_lsb_id
touch /etc/dockerimage_lsb_id
touch /etc/dockerimage_lsb_release
touch /etc/dockerimage_lsb_codename

# Collect distribution specific informations
case "$LSB_FAMILY" in
Debian|RedHat)
lsb_release -i -s > /etc/dockerimage_distribution
lsb_release -r -s > /etc/dockerimage_distribution_version
lsb_release -a > /etc/dockerimage_lsb
lsb_release -i -s > /etc/dockerimage_lsb_id
lsb_release -d -s > /etc/dockerimage_lsb_id
lsb_release -r -s > /etc/dockerimage_lsb_release
lsb_release -c -s > /etc/dockerimage_lsb_codename
;;

Alpine)
cat /etc/alpine-release > /etc/dockerimage_distribution_version
;;
esac


#############################
# Uninstall
#############################

case "$LSB_FAMILY" in
Debian)
apt-get purge -y -f lsb-release
;;

RedHat)
yum erase --assumeyes redhat-lsb-core
yum autoremove --assumeyes
;;
esac
12 changes: 7 additions & 5 deletions baselayout/usr/local/bin/generate-locales
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#!/bin/bash

set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail ## trace ERR through pipes
set -o errtrace ## trace ERR through 'time command' and other functions
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

LSB_DISTRIBUTION=$(cat /etc/dockerimage_distribution)
LSB_DISTRIBUTION_VERSION=$(cat /etc/dockerimage_distribution_version)

#######################################
## Debian
#######################################

if [[ "$(lsb_release -i -s)" == "Debian" ]]; then
if [[ "$LSB_DISTRIBUTION" == "Debian" ]]; then
/usr/local/bin/apt-install locales-all
fi

#######################################
## Ubuntu
#######################################

if [[ "$(lsb_release -i -s)" == "Ubuntu" ]]; then
if [[ "$(lsb_release -r -s | cut -f 1 -d .)" -ge "16" ]]; then
if [[ "$LSB_DISTRIBUTION" == "Ubuntu" ]]; then
if [[ "$(echo $LSB_DISTRIBUTION_VERSION| cut -f 1 -d .)" -ge "16" ]]; then
# Ubuntu 16.04 or later
/usr/local/bin/apt-install locales-all
else
Expand Down
2 changes: 2 additions & 0 deletions conf/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ provision:
piwik:
configuration:
piwik/general : '*'
typo3-solr:
baselayout: on
varnish:
configuration:
varnish/general : '*'
Expand Down
4 changes: 2 additions & 2 deletions docker/apache-dev/alpine-3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/centos-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/debian-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/debian-8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/debian-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-12.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-14.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-15.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-15.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-16.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache-dev/ubuntu-16.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY conf/ /opt/docker/
# Install apache
RUN echo \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache-dev \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
4 changes: 2 additions & 2 deletions docker/apache/alpine-3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN /usr/local/bin/apk-install \
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
' /etc/apache2/httpd.conf \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
with_items:
- 'a2dismod mpm_event'
- 'a2enmod mpm_event'
when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8)
when: (ansible_distribution == 'Ubuntu' and dockerimage_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and dockerimage_distribution_version|int >= 8)

- name: Manage modules [Alpine family]
lineinfile:
Expand Down
4 changes: 2 additions & 2 deletions docker/apache/centos-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN /usr/local/bin/yum-install \
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
' /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ssl.conf \
&& /opt/docker/bin/provision run --tag bootstrap --role webdevops-apache \
&& /opt/docker/bin/bootstrap.sh

&& /opt/docker/bin/bootstrap.sh \
&& /usr/local/bin/docker-image-cleanup

EXPOSE 80 443
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
with_items:
- 'a2dismod mpm_event'
- 'a2enmod mpm_event'
when: (ansible_distribution == 'Ubuntu' and ansible_lsb.major_release|int >= 14) or (ansible_distribution == 'Debian' and ansible_lsb.major_release|int >= 8)
when: (ansible_distribution == 'Ubuntu' and dockerimage_distribution_version|int >= 14) or (ansible_distribution == 'Debian' and dockerimage_distribution_version|int >= 8)

- name: Manage modules [Alpine family]
lineinfile:
Expand Down

0 comments on commit 0146d00

Please sign in to comment.