-
Notifications
You must be signed in to change notification settings - Fork 6
/
DockerMake.yml
282 lines (253 loc) · 8.92 KB
/
DockerMake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# vim: sts=2 ts=2 sw=2 ft=yaml
# Debian family
# LAYERS
base:
ignore: |
*.pyc
*~
*.tmp
build: |
MAINTAINER Petr Michalec "<[email protected]>"
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