Permalink
Fetching contributors…
Cannot retrieve contributors at this time
283 lines (253 sloc) 8.92 KB
# vim: sts=2 ts=2 sw=2 ft=yaml
# Debian family
# LAYERS
base:
ignore: |
*.pyc
*~
*.tmp
build: |
MAINTAINER Petr Michalec "<epcim@apealive.net>"
ENV LC_ALL C
ENV LANG C.UTF-8
ENV LANGUAGE $LANG
ENV TZ Etc/UTC
ENV LAYER_PKGUPDT "apt-get update -q"
ENV LAYER_INSTALL "apt-get install -y --no-install-recommends "
ENV LAYER_CLEANUP "apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache /home/*/.cache"
ENV DEBIAN_FRONTEND "noninteractive"
common-cleanup:
build: |
RUN echo "Layer common cleanup" \
&& eval ${LAYER_CLEANUP}
common:
build: |
RUN echo "Layer with common packages" \
&& eval ${LAYER_PKGUPDT} \
&& apt-get upgrade -qy \
&& ${LAYER_INSTALL} \
curl \
git \
rsync \
sudo \
vim-tiny \
wget \
\
apt-transport-https \
ca-certificates \
netcat \
tzdata \
gnupg2 \
zlib1g-dev \
&& eval ${LAYER_CLEANUP}
salt:
requires:
- python
build: |
ARG SALT_VERSION="stable"
ENV SALT_VERSION $SALT_VERSION
ARG SALT_BOOTSTRAP_PKGS="-p gcc -p python-pip -p python-setuptools -p python-wheel -p python-dev"
ENV SALT_BOOTSTRAP_PKGS $SALT_BOOTSTRAP_PKGS
ARG SALT_BOOTSTRAP_OPTS="-PdX ${SALT_VERSION}"
ENV SALT_BOOTSTRAP_OPTS $SALT_BOOTSTRAP_OPTS
RUN echo "Layer salt" \
&& eval ${LAYER_PKGUPDT} \
&& mkdir -p /var/run/salt /var/cache/salt /var/log/salt /etc/salt/pki/master/minions /srv/salt/formula /srv/salt/env \
&& curl -qL https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh | $SUDO sh -s -- ${SALT_BOOTSTRAP_PKGS} -M -A localhost ${SALT_BOOTSTRAP_OPTS} \
&& if ! getent passwd salt > /dev/null;then useradd --system salt; fi \
&& chown -R salt:salt /etc/salt /var/cache/salt /var/log/salt /var/run/salt \
&& eval ${LAYER_CLEANUP}
python:
build: |
ARG PYTHON_VERSION="3"
ENV PYTHON_VERSION $PYTHON_VERSION
RUN echo "Layer python and dev/prerequisites" \
&& eval ${LAYER_PKGUPDT} \
&& ${LAYER_INSTALL} \
apt-utils \
&& ${LAYER_INSTALL} \
gcc \
libssl-dev \
libpython-dev \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-pip \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-wheel \
python${PYTHON_VERSION}-setuptools \
&& eval ${LAYER_CLEANUP}
salt-formulas:
requires:
- python
build: |
ARG SALT_FORMULA_VERSION="master"
ENV SALT_FORMULA_VERSION $SALT_FORMULA_VERSION
ARG SALT_FORMULA_SOURCES="https://github.com/salt-formulas https://github.com/saltstack-formulas"
ENV SALT_FORMULA_SOURCES $SALT_FORMULA_SOURCES
ARG SALT_FORMULAS_BASE="/srv/salt/formula"
ENV SALT_FORMULAS_BASE $SALT_FORMULAS_BASE
ARG SALT_ENV_PATH_="/srv/salt/env/prd"
ENV SALT_ENV_PATH_ $SALT_ENV_PATH_
ARG RECLASS_BASE="/srv/salt/reclass"
ENV RECLASS_BASE $RECLASS_BASE
RUN echo "Layer python/salt module prerequisites, formulas" \
&& mkdir -p /srv/salt \
&& curl -sSqL https://raw.githubusercontent.com/salt-formulas/salt-formulas-scripts/master/formula-fetch.sh -o /srv/salt/formula-fetch.sh \
&& bash -c 'source /srv/salt/formula-fetch.sh && setupPyEnv && fetchAll' \
&& eval ${LAYER_CLEANUP}
wheel:
requires:
- base
- python
build: |
ARG WHEELHOUSE_VERSION="master"
ENV WHEELHOUSE_VERSION $WHEELHOUSE_VERSION
# NOTE, wheelhouse requires at least ruamel v0.15.x (debian:stretch has 0.13.x as of 2018.2)
# python-ruamel.yaml \
# FIXME, use pipenv --system to install dependencies
RUN echo "Layer wheelhouse" \
&& git clone https://github.com/epcim/wheelhouse.git /wh \
&& cd /wh && git checkout origin/$WHEELHOUSE_VERSION \
&& LANG=C LC_ALL=C pip install -r /wh/requirements.txt
reclass:
requires:
- salt
- salt-formulas
- tini-saltmaster
build: |
ARG SALT_EXT_PILLAR="reclass"
ENV SALT_EXT_PILLAR $SALT_EXT_PILLAR
ARG RECLASS_VERSION="master"
ENV RECLASS_VERSION $RECLASS_VERSION
ARG SALT_ENV_PATH_="/srv/salt/env/prd"
ENV SALT_ENV_PATH_ $SALT_ENV_PATH_
ARG RECLASS_BASE="/srv/salt/reclass"
ENV RECLASS_BASE $RECLASS_BASE
RUN echo "Layer reclass" \
&& mkdir -p /etc/reclass $RECLASS_BASE/classes/system \
&& git clone https://github.com/Mirantis/reclass-system-salt-model $RECLASS_BASE/classes/system \
&& find $RECLASS_BASE/classes/system
RUN pip install --install-option="--prefix=/usr/local" -I \
"git+https://github.com/salt-formulas/reclass.git@$RECLASS_VERSION"
# NOTE, to consider --upgrade --force-reinstall
# VOLUME ["/etc/salt/pki" "/srv/salt/env" "/srv/salt/pillar" "$RECLASS_BASE"]
saltclass:
requires:
- salt
- salt-formulas
- tini-saltmaster
build: |
ARG SALT_EXT_PILLAR="saltclass"
ENV SALT_EXT_PILLAR $SALT_EXT_PILLAR
ARG SALT_ENV_PATH_="/srv/salt/env/prd"
ENV SALT_ENV_PATH_ $SALT_ENV_PATH_
ARG SALTCLASS_BASE="/srv/salt/saltclass"
ENV SALTCLASS_BASE $SALTCLASS_BASE
# VOLUME ["/etc/salt/pki" "/srv/salt/env" "/srv/salt/pillar" "$SALTCLASS_BASE"]
RUN echo "Layer saltclass" \
&& mkdir -p mkdir $SALTCLASS_BASE/classes/system \
&& git clone https://github.com/epcim/saltclass-system $SALTCLASS_BASE/classes/system \
&& find $RECLASS_BASE/classes/system \
&& for i in $(grep -r -e '^applications:' -e '^parameters:' -l $SALTCLASS_BASE); do \
sed -i 's/applications:/states:/g;s/parameters:/pillars:/g' $i; \
done
tini:
build: |
ENV TINI_VERSION 0.16.1
ENV TINI_PGP 0527A9B7
ENV TINI_URL https://github.com/krallin/tini/releases/download
RUN gpg --keyserver keyserver.ubuntu.com --recv-key ${TINI_PGP} \
&& curl -s -S -L "${TINI_URL}/v${TINI_VERSION}/tini-static-$(dpkg --print-architecture).asc" -o /bin/tini.asc \
&& curl -s -S -L "${TINI_URL}/v${TINI_VERSION}/tini-static-$(dpkg --print-architecture)" -o /bin/tini \
&& gpg --verify /bin/tini.asc \
&& rm /bin/tini.asc \
&& chmod +x /bin/tini
#COPY files/entrypoint.sh /entrypoint.sh
#ENTRYPOINT ["/bin/tini", "--", "/entrypoint.sh"]
tini-saltmaster:
build_directory: .
requires:
- tini
build: |
ARG RECLASS_BASE="/srv/salt/reclass"
ENV RECLASS_BASE $RECLASS_BASE
ARG SALTCLASS_BASE="/srv/salt/saltclass"
ENV SALTCLASS_BASE $SALTCLASS_BASE
# VOLUME [ "/etc/salt/pki" "/srv/salt/env" "/srv/salt/pillar" "$RECLASS_BASE" "$SALTCLASS_BASE" ]
ADD files/reclass/reclass-config.yml /etc/reclass/
ADD files/salt/master.conf /etc/salt/master.d/
ADD files/salt/saltclass.conf /tmp/
ADD files/salt/reclass.conf /tmp/
COPY files/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/tini", "--", "/entrypoint.sh"]
EXPOSE 4505 4506
# BASE IMAGES
debian-stretch:
FROM: debian:stretch
requires:
- base
- common
build: |
RUN echo "Layer base image specifics" \
&& eval ${LAYER_PKGUPDT} \
&& ${LAYER_INSTALL} \
locales \
locales-all \
&& update-locale LANG=en_US.UTF-8 \
&& eval ${LAYER_CLEANUP}
# Note, debian:ubuntu install locales though different packages
locales:
build: |
RUN echo "Layer base image specifics" \
&& eval ${LAYER_PKGUPDT} \
&& ${LAYER_INSTALL} \
locales \
language-pack-en \
&& update-locale LANG=en_US.UTF-8 \
&& eval ${LAYER_CLEANUP}
ubuntu-bionic:
FROM: ubuntu:bionic
requires:
- base
- common
- locales
ubuntu-xenial:
FROM: ubuntu:xenial
requires:
- base
- common
- locales
ubuntu-trusty:
FROM: ubuntu:trusty
requires:
- base
- common
- locales
# DEPRECATED salt-formulas-pkg
salt-formulas-pkg:
build: |
ARG SALT_FORMULA_VERSION="nightly"
ENV SALT_FORMULA_VERSION $SALT_FORMULA_VERSION
ENV APT_REPOSITORY "deb http://apt.mirantis.com/xenial ${SALT_FORMULA_VERSION} salt"
ENV APT_REPOSITORY_GPG "http://apt.mirantis.com/public.gpg"
# FIXME, these prereq. should be installed platform independent way by the formula pkg itself
RUN echo "Layer salt, salt-formulas prerequisites" \
&& eval ${LAYER_PKGUPDT} \
&& ${LAYER_INSTALL} \
gcc \
gpgv \
gnupg2 \
python-pip \
python-wheel \
python-setuptools \
python-dev \
&& eval ${LAYER_CLEANUP}
RUN echo "Layer salt-formulas" \
&& echo "$APT_REPOSITORY" | tee /etc/apt/sources.list.d/salt-formulas.list >/dev/null \
&& curl -sL $APT_REPOSITORY_GPG | $SUDO apt-key add - \
&& eval ${LAYER_PKGUPDT} \
&& ${LAYER_INSTALL} "salt-formula-*" -y --fix-missing -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
&& mkdir -p /srv/salt/env/dev \
&& ln -s /usr/share/salt-formulas/env /srv/salt/env/prd \
&& eval ${LAYER_CLEANUP}
#
# TODO, Alternative install salt-formulas from git