-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Dockerfile-5.2
857 lines (729 loc) · 29.9 KB
/
Dockerfile-5.2
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# vi: ft=dockerfile
# Auto-generated via Ansible: edit ./ansible/DOCKERFILES/Dockerfile-work.j2 instead.
########################################################################################################################
########################################################################################################################
###
### Stage 1/7: Devilbox work image (HELP BUILDER)
###
########################################################################################################################
########################################################################################################################
###
### Installs all cli tools required to install custom tools
###
FROM devilbox/php-fpm:5.2-slim as devilbox-work-help-builder
###
### Install build_dep
###
RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \
libpython-dev \
&& rm -rf /var/lib/apt/lists/*
###
### Devilbox required helper tools from group_vars (work-help.yml)
###
# -------------------- nvm --------------------
RUN set -eux \
&& NODE_VERSION="17" \
\
&& NVM_VERSION="$( \
curl -sS 'https://github.com/nvm-sh/nvm/releases' \
| grep -Eo '/nvm-sh/nvm/releases/tag/v?[.0-9]+"' \
| grep -Eo 'v?[.0-9]+' \
| sort -V \
| tail -1 \
)" \
&& mkdir -p /opt/nvm \
&& curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" \
| NVM_DIR="/opt/nvm" bash \
\
&& chown -R devilbox:devilbox "/opt/nvm" \
\
&& su -c ". /opt/nvm/nvm.sh; nvm install ${NODE_VERSION}" devilbox \
&& su -c ". /opt/nvm/nvm.sh; nvm use ${NODE_VERSION}" devilbox \
&& su -c ". /opt/nvm/nvm.sh; corepack enable" devilbox \
\
&& ln -s "/opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/corepack" /usr/local/bin/ \
&& ln -s "/opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/node" /usr/local/bin/ \
&& ln -s "/opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/npm" /usr/local/bin/ \
&& ln -s "/opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/npx" /usr/local/bin/ \
&& ln -s "/opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/yarn" /usr/local/bin/ \
\
&& chmod 0777 /opt/nvm \
&& find /opt/nvm -type f -print0 | xargs -n1 -0 chmod go+w \
&& find /opt/nvm -type d -print0 | xargs -n1 -0 chmod 0777 \
\
&& rm -rf /opt/nvm/.cache \
&& rm -rf /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/share \
&& rm -rf /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/include \
\
&& true
# -------------------- pip --------------------
RUN set -eux \
&& curl -sS -L --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python \
\
&& /bin/ls -1 /usr/local/lib/ | grep ^python | while read -r version; do \
cd "/usr/local/lib/${version}/" \
&& find . -name '*.pyc' -print0 | xargs -0 -n1 rm -rf \
&& find . -name '*.exe' -print0 | xargs -0 -n1 rm -rf \
&& find . -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
\
&& if [ -d "dist-packages" ]; then \
cd "dist-packages" \
&& pwd \
&& if /bin/ls -1 | grep -v '^pip'; then \
/bin/ls -1 | grep -v '^pip' | xargs -n1 rm -rf; \
fi \
fi \
done \
\
&& true
########################################################################################################################
########################################################################################################################
###
### Stage 2/7: Devilbox work image (HELP)
###
########################################################################################################################
########################################################################################################################
###
### Copies all cli tools required to run Devilbox and its intranet into a clean image
###
FROM devilbox/php-fpm:5.2-slim as devilbox-work-help
###
### Copy nvm
###
COPY --from=devilbox-work-help-builder /opt/nvm /opt/nvm
###
### Copy binaries (Composer & Pip binaries)
###
COPY --from=devilbox-work-help-builder /usr/local/bin /usr/local/bin
###
### Python packages
###
COPY --from=devilbox-work-help-builder /usr/local/lib /usr/local/lib
###
### Configure Bash (composer, node yarn)
###
RUN set -eux \
&& { \
#echo 'PATH="${PATH}:/usr/local/bin:/usr/local/sbin"'; \
echo; \
echo "# [Devilbox] Ensure yarn, composer and node are in PATH"; \
echo 'PATH="${HOME}/.yarn/bin:${PATH}"'; \
echo 'PATH="${HOME}/.composer/vendor/bin:${PATH}"'; \
echo 'PATH="/opt/nvm/versions/node/$(node --version)/bin:${PATH}"'; \
echo "export PATH"; \
echo; \
echo "# [Devilbox] Ensure to load nvm"; \
echo 'export NVM_DIR="/opt/nvm"'; \
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm'; \
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion'; \
#echo; \
#echo ". /etc/bash-devilbox"; \
#echo; \
#echo "if [ -d /etc/bashrc-devilbox.d/ ]; then"; \
#echo " for f in /etc/bashrc-devilbox.d/*.sh ; do"; \
#echo " if [ -r \"\${f}\" ]; then"; \
#echo " . \"\${f}\""; \
#echo " fi"; \
#echo " done"; \
#echo " unset f"; \
#echo "fi"; \
} | tee -a /home/${MY_USER}/.bashrc /root/.bashrc \
&& chown ${MY_USER}:${MY_GROUP} /home/${MY_USER}/.bashrc
########################################################################################################################
########################################################################################################################
###
### Stage 3/7: Devilbox work image (HELP TEST)
###
########################################################################################################################
########################################################################################################################
###
### Test all Devilbox cli utils if copying was successful
###
FROM devilbox-work-help as devilbox-work-help-test
###
### Devilbox required helper tools from group_vars (work-help.yml)
###
# -------------------- nvm --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; nvm --version' devilbox | grep -E '^v?[0-9][.0-9]+' \
&& su -c '. /opt/nvm/nvm.sh; node --version' devilbox | grep -E '^v?[0-9][.0-9]+' \
&& su -c '. /opt/nvm/nvm.sh; yarn --version' devilbox | grep -E '^v?[0-9][.0-9]+' \
\
&& true
# -------------------- pip --------------------
RUN set -eux \
&& pip --version \
&& true
###
### Re-activate modules which have been deactivated in mods (for testing).
###
RUN set -eux \
&& if find /usr/local/lib/php/extensions/ -name phalcon.so | grep phalcon; then \
echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/docker-php-ext-phalcon.ini; \
fi \
&& if find /usr/local/lib/php/extensions/ -name psr.so | grep psr; then \
echo "extension=psr.so" > /usr/local/etc/php/conf.d/docker-php-ext-psr.ini; \
fi \
&& if find /usr/local/lib/php/extensions/ -name xhprof.so | grep xhprof; then \
echo "extension=xhprof.so" > /usr/local/etc/php/conf.d/docker-php-ext-xhprof.ini; \
fi
###
### Check if PHP still works
###
RUN set -eux \
&& echo "date.timezone=UTC" > /usr/local/etc/php/php.ini \
&& php -v | grep -oE 'PHP\s[.0-9]+' | grep -oE '[.0-9]+' | grep '^5.2' \
&& /usr/local/sbin/php-fpm --test \
\
&& PHP_ERROR="$( php -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
&& PHP_ERROR="$( php -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
\
&& PHP_FPM_ERROR="$( php-fpm -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& PHP_FPM_ERROR="$( php-fpm -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& rm -f /usr/local/etc/php/php.ini
########################################################################################################################
########################################################################################################################
###
### Stage 4/7: Devilbox work image (TOOLS BUILDER)
###
########################################################################################################################
########################################################################################################################
###
### This stage can be easily modified by adding tools into the ./php_tools/ directory.
###
FROM devilbox-work-help as devilbox-work-tools-builder
###
### Install build_dep, run_dep or tools type: apt
###
RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \
# ---------- build_deps ----------
ruby-dev \
# ---------- run_deps ----------
dos2unix \
file \
moreutils \
ruby \
# ---------- type: apt ----------
git \
jq \
mupdf-tools \
net-tools \
openssh-client \
rsync \
shellcheck \
subversion \
tig \
vim \
zsh \
&& rm -rf /var/lib/apt/lists/*
###
### Install defined php_tools
###
# -------------------- (npm) angular-cli --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global @angular/cli' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/ng /usr/local/bin/ \
&& ng version 2>&1 | grep -iE 'Angular CLI:\s*[0-9][.0-9]+' || (ng version; false) \
&& true
# -------------------- (npm) eslint --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global eslint' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/eslint /usr/local/bin/ \
&& eslint -v | grep -E '[0-9][.0-9]+' || (eslint -v; false) \
&& true
# -------------------- (apt) git --------------------
RUN set -eux \
&& git --version 2>&1 | grep -E '[0-9][.0-9]+' || (git --version; false) \
&& true
# -------------------- (npm) jsonlint --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global jsonlint' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/jsonlint /usr/local/bin/ \
&& jsonlint --version | grep -E '[0-9][.0-9]+' || (jsonlint --version; false) \
&& true
# -------------------- (rubygem) mdl --------------------
RUN set -eux \
&& gem install mixlib-config -v 2.2.4 \
\
&& gem install mdl -v 0.5.0 \
&& mdl --version | grep -E '[.0-9]+' || (mdl --version; false) \
&& true
# -------------------- (custom) awesome-ci --------------------
RUN set -eux \
&& git clone https://github.com/cytopia/awesome-ci.git /tmp/awesome-ci \
&& cd /tmp/awesome-ci \
&& git checkout $(git describe --abbrev=0 --tags) \
&& ./configure --prefix=/usr/local \
&& make install \
&& cd / \
&& rm -rf /tmp/awesome-ci \
\
&& regex-grep --version | grep -E '[0-9][.0-9]+' || (regex-grep --version; false) \
&& true
# -------------------- (custom) git-flow --------------------
RUN set -eux \
&& git clone https://github.com/petervanderdoes/gitflow-avh /tmp/gitflow \
&& cd /tmp/gitflow \
&& make install \
&& cd / && rm -rf /tmp/gitflow \
\
&& git-flow version 2>&1 | grep -E '[0-9][.0-9]+' || (git-flow version; false) \
&& true
# -------------------- (npm) grunt-cli --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global grunt-cli' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/grunt /usr/local/bin/ \
&& grunt --version | grep -E '[0-9][.0-9]+' || (grunt --version; false) \
&& true
# -------------------- (npm) gulp --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global gulp' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/gulp /usr/local/bin/ \
&& gulp --version | grep -E '[0-9][.0-9]+' || (gulp --version; false) \
&& true
# -------------------- (apt) jq --------------------
RUN set -eux \
&& jq --version 2>&1 | grep -E '[0-9][.0-9]+' || (jq --version; false) \
&& true
# -------------------- (custom) linkcheck --------------------
RUN set -eux \
&& curl -sS -L --fail -o /usr/local/bin/linkcheck https://raw.githubusercontent.com/cytopia/linkcheck/master/linkcheck \
&& chmod +x /usr/local/bin/linkcheck \
&& linkcheck --version | grep -E 'v[0-9][.0-9]+' || (linkcheck --version; false) \
&& true
# -------------------- (npm) mdlint --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global mdlint' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/mdlint /usr/local/bin/ \
&& mdlint --version | grep -E '[0-9][.0-9]+' || (mdlint --version; false) \
&& true
# -------------------- (apt) mupdf-tools --------------------
RUN set -eux \
&& PHP_VERSION="$(php -v | grep ^PHP | awk '{print $2}' | grep -Eo '[0-9]\.[0-9]')" \
&& if echo "${PHP_VERSION}" | grep -E '5\.2|5\.3|5\.4|5\.5'; then \
mutool 2>&1 | grep ^usage; \
else \
echo test > test.txt \
&& mutool create -o test.pdf test.txt \
&& file test.pdf | grep 'PDF document' \
&& rm test.txt \
&& rm test.pdf; \
fi \
\
&& true
# -------------------- (apt) net-tools --------------------
RUN set -eux \
&& netstat --version | grep net-tools || (netstat --version; false) \
&& true
# -------------------- (custom) phpcbf --------------------
RUN set -eux \
&& PHPCBF_URL="https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.0/phpcbf.phar" \
&& curl -sS -k -L --fail -L "${PHPCBF_URL}" -o /usr/local/bin/phpcbf \
&& chmod +x /usr/local/bin/phpcbf \
&& phpcbf --version | grep -E 'version [0-9][.0-9]+' || (phpcbf --version; false) \
&& true
# -------------------- (custom) phpcs --------------------
RUN set -eux \
&& PHPCS_URL="https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.0/phpcs.phar" \
&& curl -sS -k -L --fail -L "${PHPCS_URL}" -o /usr/local/bin/phpcs \
&& chmod +x /usr/local/bin/phpcs \
&& phpcs --version | grep -E 'version [0-9][.0-9]+' || (phpcs --version; false) \
&& true
# -------------------- (npm) pm2 --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global pm2' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/pm2 /usr/local/bin/ \
&& pm2 --no-daemon --version | tail -1 | grep -E '[0-9][.0-9]+' || (pm2 --no-daemon --version; false) \
&& true
# -------------------- (pip) pwncat --------------------
RUN set -eux \
&& pip install --no-cache-dir --no-compile --force-reinstall pwncat \
&& ln -s pwncat /usr/local/bin/netcat \
\
&& pwncat --version 2>&1 | grep -E 'Version [0-9][.0-9]+' || (pwncat --version; false) \
&& true
# -------------------- (apt) ssh --------------------
RUN set -eux \
&& ssh -V 2>&1 | grep ^OpenSSH || (ssh -V; false) \
&& true
# -------------------- (apt) rsync --------------------
RUN set -eux \
&& rsync --version | grep version | grep -E '[0-9]\.[0-9]+' || (rsync --version; false) \
&& true
# -------------------- (npm) sass --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global sass' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/sass /usr/local/bin/ \
&& sass --version | grep -E '[0-9][.0-9]+' || (sass --version; false) \
&& true
# -------------------- (apt) shellcheck --------------------
RUN set -eux \
&& shellcheck --version | grep -E '[0-9][.0-9]+' || (shellcheck --version; false) \
&& true
# -------------------- (npm) stylelint --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global stylelint' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/stylelint /usr/local/bin/ \
&& stylelint --version | grep -E '[0-9][.0-9]+' || (stylelint --version; false) \
&& true
# -------------------- (apt) svn --------------------
RUN set -eux \
&& svn --version | grep version | grep -E '[0-9]+\.[0-9]+' || (svn --version; false) \
&& true
# -------------------- (custom) symfony-cli --------------------
RUN set -eux \
&& curl -sS https://get.symfony.com/cli/installer | bash -s -- --install-dir /usr/local/bin \
&& symfony --no-ansi -V | grep -E 'version [0-9][.0-9]+' || (symfony --no-ansi -V; false) \
&& true
# -------------------- (custom) taskfile --------------------
RUN set -eux \
&& sh -c "$(curl -sS -K --fail -k https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin/ \
&& task --version | grep -E '[0-9][.0-9]+' || (task --version; false) \
&& true
# -------------------- (apt) tig --------------------
RUN set -eux \
&& tig --version 2>&1 | grep -E '[0-9][.0-9]+' || (tig --version; false) \
&& true
# -------------------- (apt) vim --------------------
RUN set -eux \
&& vim --version | grep ^VIM | grep -E '[0-9]\.[0-9]+' || (vim --version; false) \
&& true
# -------------------- (npm) vue-cli --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global @vue/cli' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/vue /usr/local/bin/ \
&& vue --version | grep -E '[0-9][.0-9]+' || (vue --version; false) \
&& true
# -------------------- (npm) webpack-cli --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global webpack-cli' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/webpack-cli /usr/local/bin/ \
&& webpack-cli --version | grep -E '[0-9][.0-9]+' || (webpack-cli --version; false) \
&& true
# -------------------- (npm) wscat --------------------
RUN set -eux \
&& su -c '. /opt/nvm/nvm.sh; npm install --location=global wscat' devilbox \
&& ln -s /opt/nvm/versions/node/$(su -c '. /opt/nvm/nvm.sh; node --version' devilbox)/bin/wscat /usr/local/bin/ \
&& wscat --version | grep -E '[0-9][.0-9]+' || (wscat --version; false) \
&& true
# -------------------- (pip) yamllint --------------------
RUN set -eux \
&& pip install --no-cache-dir --no-compile --force-reinstall yamllint \
&& yamllint --version 2>&1 | grep -E '[0-9][.0-9]+' || (yamllint --version; false) \
&& true
# -------------------- (pip) yq --------------------
RUN set -eux \
&& pip install --no-cache-dir --no-compile --force-reinstall yq \
&& yq --version 2>&1 | grep -E '[0-9][.0-9]+' || (yq --version; false) \
&& true
# -------------------- (apt) zsh --------------------
RUN set -eux \
&& zsh --version 2>&1 | grep -E '[0-9][.0-9]+' || (zsh --version; false) \
&& true
###
### Post fixes
###
RUN set -eux \
&& if [ ! -d "/var/lib/gems" ]; then \
mkdir "/var/lib/gems"; \
fi
########################################################################################################################
########################################################################################################################
###
### Stage 5/7: Devilbox work image (TOOLS)
###
########################################################################################################################
########################################################################################################################
###
### This stage can be easily modified by adding tools into the ./php_tools/ directory.
###
FROM devilbox-work-help as devilbox-work-tools
###
### Install run_dep or tools type: apt
###
RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \
# ---------- run_deps ----------
dos2unix \
file \
moreutils \
ruby \
# ---------- type: apt ----------
git \
jq \
mupdf-tools \
net-tools \
openssh-client \
rsync \
shellcheck \
subversion \
tig \
vim \
zsh \
&& rm -rf /var/lib/apt/lists/*
###
### Copy Custom (binaries in /usr/local/bin)
###
COPY --from=devilbox-work-tools-builder /usr/local/bin /usr/local/bin
###
### Copy NPM
###
COPY --from=devilbox-work-tools-builder /opt/nvm /opt/nvm
###
### Copy Composer
###
COPY --from=devilbox-work-tools-builder /usr/local/src /usr/local/src
###
### Copy Pip
###
COPY --from=devilbox-work-tools-builder /usr/local/lib /usr/local/lib
###
### Copy RubyGems
###
COPY --from=devilbox-work-tools-builder /var/lib/gems /var/lib/gems
# FIXME: / TODO: Add post: stage into here as well
########################################################################################################################
########################################################################################################################
###
### Stage 6/7: Devilbox work image (TOOLS TEST)
###
########################################################################################################################
########################################################################################################################
###
### Test all Devilbox cli utils if copying was successful
###
FROM devilbox-work-tools as devilbox-work-tools-test
# -------------------- (npm) angular-cli --------------------
RUN set -eux \
&& ng version 2>&1 | grep -iE 'Angular CLI:\s*[0-9][.0-9]+' || (ng version; false) \
&& true
# -------------------- (npm) eslint --------------------
RUN set -eux \
&& eslint -v | grep -E '[0-9][.0-9]+' || (eslint -v; false) \
&& true
# -------------------- (apt) git --------------------
RUN set -eux \
&& git --version 2>&1 | grep -E '[0-9][.0-9]+' || (git --version; false) \
&& true
# -------------------- (npm) jsonlint --------------------
RUN set -eux \
&& jsonlint --version | grep -E '[0-9][.0-9]+' || (jsonlint --version; false) \
&& true
# -------------------- (rubygem) mdl --------------------
RUN set -eux \
&& mdl --version | grep -E '[.0-9]+' || (mdl --version; false) \
&& true
# -------------------- (custom) awesome-ci --------------------
RUN set -eux \
&& regex-grep --version | grep -E '[0-9][.0-9]+' || (regex-grep --version; false) \
&& true
# -------------------- (custom) git-flow --------------------
RUN set -eux \
&& git-flow version 2>&1 | grep -E '[0-9][.0-9]+' || (git-flow version; false) \
&& true
# -------------------- (npm) grunt-cli --------------------
RUN set -eux \
&& grunt --version | grep -E '[0-9][.0-9]+' || (grunt --version; false) \
&& true
# -------------------- (npm) gulp --------------------
RUN set -eux \
&& gulp --version | grep -E '[0-9][.0-9]+' || (gulp --version; false) \
&& true
# -------------------- (apt) jq --------------------
RUN set -eux \
&& jq --version 2>&1 | grep -E '[0-9][.0-9]+' || (jq --version; false) \
&& true
# -------------------- (custom) linkcheck --------------------
RUN set -eux \
&& linkcheck --version | grep -E 'v[0-9][.0-9]+' || (linkcheck --version; false) \
&& true
# -------------------- (npm) mdlint --------------------
RUN set -eux \
&& mdlint --version | grep -E '[0-9][.0-9]+' || (mdlint --version; false) \
&& true
# -------------------- (apt) mupdf-tools --------------------
RUN set -eux \
&& PHP_VERSION="$(php -v | grep ^PHP | awk '{print $2}' | grep -Eo '[0-9]\.[0-9]')" \
&& if echo "${PHP_VERSION}" | grep -E '5\.2|5\.3|5\.4|5\.5'; then \
mutool 2>&1 | grep ^usage; \
else \
echo test > test.txt \
&& mutool create -o test.pdf test.txt \
&& file test.pdf | grep 'PDF document' \
&& rm test.txt \
&& rm test.pdf; \
fi \
\
&& true
# -------------------- (apt) net-tools --------------------
RUN set -eux \
&& netstat --version | grep net-tools || (netstat --version; false) \
&& true
# -------------------- (custom) phpcbf --------------------
RUN set -eux \
&& phpcbf --version | grep -E 'version [0-9][.0-9]+' || (phpcbf --version; false) \
&& true
# -------------------- (custom) phpcs --------------------
RUN set -eux \
&& phpcs --version | grep -E 'version [0-9][.0-9]+' || (phpcs --version; false) \
&& true
# -------------------- (npm) pm2 --------------------
RUN set -eux \
&& pm2 --no-daemon --version | tail -1 | grep -E '[0-9][.0-9]+' || (pm2 --no-daemon --version; false) \
&& true
# -------------------- (pip) pwncat --------------------
RUN set -eux \
&& pwncat --version 2>&1 | grep -E 'Version [0-9][.0-9]+' || (pwncat --version; false) \
&& true
# -------------------- (apt) ssh --------------------
RUN set -eux \
&& ssh -V 2>&1 | grep ^OpenSSH || (ssh -V; false) \
&& true
# -------------------- (apt) rsync --------------------
RUN set -eux \
&& rsync --version | grep version | grep -E '[0-9]\.[0-9]+' || (rsync --version; false) \
&& true
# -------------------- (npm) sass --------------------
RUN set -eux \
&& sass --version | grep -E '[0-9][.0-9]+' || (sass --version; false) \
&& true
# -------------------- (apt) shellcheck --------------------
RUN set -eux \
&& shellcheck --version | grep -E '[0-9][.0-9]+' || (shellcheck --version; false) \
&& true
# -------------------- (npm) stylelint --------------------
RUN set -eux \
&& stylelint --version | grep -E '[0-9][.0-9]+' || (stylelint --version; false) \
&& true
# -------------------- (apt) svn --------------------
RUN set -eux \
&& svn --version | grep version | grep -E '[0-9]+\.[0-9]+' || (svn --version; false) \
&& true
# -------------------- (custom) symfony-cli --------------------
RUN set -eux \
&& symfony --no-ansi -V | grep -E 'version [0-9][.0-9]+' || (symfony --no-ansi -V; false) \
&& true
# -------------------- (custom) taskfile --------------------
RUN set -eux \
&& task --version | grep -E '[0-9][.0-9]+' || (task --version; false) \
&& true
# -------------------- (apt) tig --------------------
RUN set -eux \
&& tig --version 2>&1 | grep -E '[0-9][.0-9]+' || (tig --version; false) \
&& true
# -------------------- (apt) vim --------------------
RUN set -eux \
&& vim --version | grep ^VIM | grep -E '[0-9]\.[0-9]+' || (vim --version; false) \
&& true
# -------------------- (npm) vue-cli --------------------
RUN set -eux \
&& vue --version | grep -E '[0-9][.0-9]+' || (vue --version; false) \
&& true
# -------------------- (npm) webpack-cli --------------------
RUN set -eux \
&& webpack-cli --version | grep -E '[0-9][.0-9]+' || (webpack-cli --version; false) \
&& true
# -------------------- (npm) wscat --------------------
RUN set -eux \
&& wscat --version | grep -E '[0-9][.0-9]+' || (wscat --version; false) \
&& true
# -------------------- (pip) yamllint --------------------
RUN set -eux \
&& yamllint --version 2>&1 | grep -E '[0-9][.0-9]+' || (yamllint --version; false) \
&& true
# -------------------- (pip) yq --------------------
RUN set -eux \
&& yq --version 2>&1 | grep -E '[0-9][.0-9]+' || (yq --version; false) \
&& true
# -------------------- (apt) zsh --------------------
RUN set -eux \
&& zsh --version 2>&1 | grep -E '[0-9][.0-9]+' || (zsh --version; false) \
&& true
###
### Re-activate modules which have been deactivated in mods (for testing).
###
RUN set -eux \
&& if find /usr/local/lib/php/extensions/ -name phalcon.so | grep phalcon; then \
echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/docker-php-ext-phalcon.ini; \
fi \
&& if find /usr/local/lib/php/extensions/ -name psr.so | grep psr; then \
echo "extension=psr.so" > /usr/local/etc/php/conf.d/docker-php-ext-psr.ini; \
fi \
&& if find /usr/local/lib/php/extensions/ -name xhprof.so | grep xhprof; then \
echo "extension=xhprof.so" > /usr/local/etc/php/conf.d/docker-php-ext-xhprof.ini; \
fi
###
### Check if PHP still works
###
RUN set -eux \
&& echo "date.timezone=UTC" > /usr/local/etc/php/php.ini \
&& php -v | grep -oE 'PHP\s[.0-9]+' | grep -oE '[.0-9]+' | grep '^5.2' \
&& /usr/local/sbin/php-fpm --test \
\
&& PHP_ERROR="$( php -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
&& PHP_ERROR="$( php -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_ERROR}" ]; then echo "${PHP_ERROR}"; false; fi \
\
&& PHP_FPM_ERROR="$( php-fpm -v 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& PHP_FPM_ERROR="$( php-fpm -i 2>&1 1>/dev/null )" \
&& if [ -n "${PHP_FPM_ERROR}" ]; then echo "${PHP_FPM_ERROR}"; false; fi \
&& rm -f /usr/local/etc/php/php.ini
########################################################################################################################
########################################################################################################################
###
### Stage 7/7: Devilbox sliwork image (FINAL)
###
########################################################################################################################
########################################################################################################################
###
### Prepare final base image (STAGE: work)
###
FROM devilbox-work-tools as work
MAINTAINER "cytopia" <[email protected]>
###
### Labels
###
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
#LABEL "org.opencontainers.image.created"=""
#LABEL "org.opencontainers.image.version"=""
#LABEL "org.opencontainers.image.revision"=""
LABEL "maintainer"="cytopia <[email protected]>"
LABEL "org.opencontainers.image.authors"="cytopia <[email protected]>"
LABEL "org.opencontainers.image.url"="https://github.com/devilbox/docker-php-fpm"
LABEL "org.opencontainers.image.documentation"="https://github.com/devilbox/docker-php-fpm"
LABEL "org.opencontainers.image.source"="https://github.com/devilbox/docker-php-fpm"
LABEL "org.opencontainers.image.vendor"="devilbox"
LABEL "org.opencontainers.image.licenses"="MIT"
LABEL "org.opencontainers.image.ref.name"="5.2-work"
LABEL "org.opencontainers.image.title"="PHP-FPM 5.2-work"
LABEL "org.opencontainers.image.description"="PHP-FPM 5.2-work"
###
### Volumes
###
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail
###
### Ports
###
EXPOSE 9000
###
### Where to start inside the container
###
WORKDIR /shared/httpd
###
### Entrypoint
###
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
ENTRYPOINT ["/docker-entrypoint.sh"]