-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.tmpl
225 lines (203 loc) · 7.17 KB
/
Dockerfile.tmpl
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
########
# Base #
########
FROM debian:bookworm-slim
ARG DEBIAN_FRONTEND="noninteractive"
ARG MANALA_USER_ID="1000"
ARG MANALA_GROUP_ID="1000"
ARG GOMPLATE_VERSION="3.11.7"
ARG DIRENV_VERSION="2.33.0"
# The 'container' environment variable tells systemd that it's running inside a
# Docker container environment.
# It's also internally used for checking we're running inside a container.
ENV container="docker"
# Default locale
ENV LANG C.UTF-8
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \
apt-get --quiet update \
&& apt-get --quiet --yes --purge --autoremove upgrade \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
s6 \
sudo \
curl \
ca-certificates \
gnupg \
libarchive-tools bzip2 \
bash-completion \
rsync \
git \
make \
less \
vim \
socat \
# User
&& addgroup --gid ${MANALA_GROUP_ID} lazy \
&& adduser --home /home/lazy --shell /bin/bash --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \
&& install --verbose --mode 0755 --group lazy --owner lazy --directory /run/user/${MANALA_USER_ID} \
&& echo "lazy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/lazy \
# Gomplate
&& curl -sSL "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}" \
--output /usr/local/bin/gomplate \
&& chmod +x /usr/local/bin/gomplate \
# Direnv
&& curl -sSL "https://github.com/direnv/direnv/releases/download/v${DIRENV_VERSION}/direnv.linux-{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}" \
--output /usr/local/bin/direnv \
&& chmod +x /usr/local/bin/direnv \
# Bash completion
&& install --verbose --mode 0755 --directory /etc/bash_completion.d \
# Oh My Bash
&& git clone https://github.com/ohmybash/oh-my-bash.git /usr/local/share/oh-my-bash \
# Clean
&& rm -rf /var/lib/apt/lists/*
##########
# System #
##########
{{ $apt := .Vars.system.apt -}}
RUN \
apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
unzip \
{{- range $package := $apt.packages }}
{{ $package }} \
{{- end }}
# Clean
&& rm -rf /var/lib/apt/lists/*
{{ if .Vars.system.docker -}}
# Docker
RUN \
curl -sSL https://download.docker.com/linux/debian/gpg \
--output /etc/apt/keyrings/docker.asc \
&& printf "\
Types: deb\n\
URIs: https://download.docker.com/linux/debian\n\
Suites: {{ include "os_release" "VERSION_CODENAME" }}\n\
Components: stable\n\
Signed-By: /etc/apt/keyrings/docker.asc\n\
" > /etc/apt/sources.list.d/docker.sources \
&& apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
docker-ce-cli \
# Clean
&& rm -rf /var/lib/apt/lists/*
{{ end -}}
{{ $goss := .Vars.system.goss -}}
{{ if $goss.version -}}
# Goss
RUN \
curl -sSL "https://github.com/goss-org/goss/releases/download/v{{ $goss.version }}/goss-linux-{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}" \
--output /usr/local/bin/goss \
&& chmod +x /usr/local/bin/goss
{{ end -}}
# Nginx
{{ $nginx := .Vars.system.nginx -}}
RUN \
curl -sSL http://nginx.org/keys/nginx_signing.key \
--output /etc/apt/keyrings/nginx.asc \
&& printf "\
Types: deb\n\
URIs: http://nginx.org/packages/debian\n\
Suites: {{ include "os_release" "VERSION_CODENAME" }}\n\
Components: nginx\n\
Signed-By: /etc/apt/keyrings/nginx.asc\n\
" > /etc/apt/sources.list.d/nginx.sources \
&& printf "\
Package: nginx\n\
Pin: version {{ $nginx.version }}.*\n\
Pin-Priority: 1000\n\
" > /etc/apt/preferences.d/nginx \
&& apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
nginx={{ $nginx.version }}.* \
# Clean
&& rm -rf /var/lib/apt/lists/*
# Php
{{ $php := .Vars.system.php -}}
RUN \
curl -sSL https://packages.sury.org/php/apt.gpg \
--output /etc/apt/keyrings/sury_php.gpg \
&& printf "\
Types: deb\n\
URIs: https://packages.sury.org/php/\n\
Suites: {{ include "os_release" "VERSION_CODENAME" }}\n\
Components: main\n\
Signed-By: /etc/apt/keyrings/sury_php.gpg\n\
" > /etc/apt/sources.list.d/sury_php.sources \
&& apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
php{{ $php.version }}-cli \
php{{ $php.version }}-fpm \
php{{ $php.version }}-opcache \
php{{ $php.version }}-xdebug \
# Symfony
php{{ $php.version }}-intl \
php{{ $php.version }}-curl \
php{{ $php.version }}-mbstring \
php{{ $php.version }}-xml \
# Project
{{- range $php.extensions }}
php{{ $php.version }}-{{ . }} \
{{- end }}
&& apt-get --quiet --yes --purge --autoremove upgrade \
&& phpdismod xdebug \
&& install --verbose --mode 0755 --directory /run/php \
&& update-alternatives --install /usr/sbin/php-fpm php-fpm /usr/sbin/php-fpm{{ $php.version }} 1 \
&& update-alternatives --install /etc/php/default php-config-default /etc/php/{{ $php.version }} 1 \
# Composer
&& curl -sSL https://getcomposer.org/installer \
| php -- --install-dir /usr/local/bin --filename composer \
# Symfony
&& curl -sSL "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_linux_{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}.tar.gz" \
| bsdtar -xvf - -C /usr/local/bin symfony \
# Clean
&& rm -rf /var/lib/apt/lists/*
{{ $nodejs := .Vars.system.nodejs -}}
{{ if $nodejs.version -}}
# Nodejs
RUN \
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key \
--output /etc/apt/keyrings/nodesource.asc \
&& printf "\
Types: deb\n\
URIs: https://deb.nodesource.com/node_{{ $nodejs.version }}.x\n\
Suites: {{ include "os_release" "VERSION_CODENAME" }}\n\
Components: main\n\
Signed-By: /etc/apt/keyrings/nodesource.asc\n\
" > /etc/apt/sources.list.d/nodesource.sources \
&& printf "\
Package: nodejs\n\
Pin: origin deb.nodesource.com\n\
Pin-Priority: 1000\n\
" > /etc/apt/preferences.d/nodejs \
&& curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg \
--output /etc/apt/keyrings/yarn.asc \
&& printf "\
Types: deb\n\
URIs: https://dl.yarnpkg.com/debian/\n\
Suites: stable\n\
Components: main\n\
Signed-By: /etc/apt/keyrings/yarn.asc\n\
" > /etc/apt/sources.list.d/yarn.sources \
&& apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
nodejs \
yarn \
# Clean
&& rm -rf /var/lib/apt/lists/*
{{ end -}}
{{ if .Vars.deploy.inventory -}}
# Ansistrano
RUN \
apt-get --quiet update \
&& apt-get --quiet --yes --no-install-recommends --verbose-versions install \
openssh-client \
ansible \
&& ansible-galaxy install --roles-path /usr/share/ansible/roles \
ansistrano.deploy,3.14.0 \
ansistrano.rollback,3.1.0 \
# Clean
&& rm -rf /var/lib/apt/lists/*
{{ end -}}
# Run
COPY docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]