Skip to content

Commit 44429a3

Browse files
committed
[Elao - App] Docker applications
1 parent 54d19ae commit 44429a3

File tree

10 files changed

+213
-51
lines changed

10 files changed

+213
-51
lines changed

MIGRATION.md

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
- vagrant destroy && rm -Rf .vagrant
2+
3+
- Récupération des parametres Vagrantfile vers le .manala.yaml
4+
- app.name -> system.hostname + ".vm"
5+
- app.box_version 3.* -> system.version 8
6+
app.box_version 4.* -> system.version 9
7+
- app.box_memory -> system.memory *si* différent de 1024 ou 2048
8+
- Suppression du fichier Vagrantfile
9+
10+
- Nettoyage du/des Makefile
11+
- Suppression des `.PHONY: build test`
12+
- Suppression des `## Colors`
13+
- Suppression des `## Help`
14+
- `-include .manala/make/Makefile` -> `-include .manala/Makefile`
15+
- Suppression des "HOSTNAME", "APP_HOSTNAME" et "_check_*"
16+
- Déplacement de target setup vers define setup
17+
```
18+
if [ -d "./var/cache" ]; then rm -rf ./var/cache; fi; define setup
19+
if [ -d "./var/log" ]; then rm -rf ./var/log; fi; -> $(VAGRANT_MAKE) install build
20+
vagrant up --no-provision endef
21+
vagrant provision
22+
vagrant ssh -- "cd /srv/app && make install && make build"
23+
```
24+
- Suppression de la partie "Environment"
25+
- Remplacement des `make -C` par des `$(MAKE) --directory `
26+
- Custom -> App
27+
-
28+
```
29+
########## #########
30+
# Build # -> # Build #
31+
########## #########
32+
```
33+
34+
- Un petit tour dans le readme, notament:
35+
- Requirements
36+
```
37+
* Make
38+
* Vagrant 2.2.10+
39+
* Landrush 1.3.2+
40+
* VirtualBox 6.1.12+
41+
* Docker Desktop 2.2.0+
42+
```
43+
- Usage: vagrant -> make
44+
45+
- Remplacement des credentials db dans .env/.env.test`
46+
```
47+
DATABASE_URL=mysql://app@127.0.0.1:3306/* -> DATABASE_URL=mysql://root@127.0.0.1:3306/*
48+
```
49+
ou dans config/paramaters.yml[.dist]
50+
```
51+
database_user: app -> database_user: root
52+
```
53+
54+
- Nettoyage du fichier .gitignore à la racine
55+
```
56+
# Vagrant
57+
.vagrant/
58+
59+
# Ansible
60+
ansible/*.retry
61+
ansible/group_vars/*_local.yml
62+
/ansible/roles/
63+
build/
64+
.manala.local.yaml
65+
```
66+
67+
- .manala.yaml
68+
- suppression de l'entrée system.symfony
69+
- Modification de l'entrée system.ssh.config
70+
```
71+
ssh: ssh:
72+
config: | client:
73+
Host previ-*.elao.prod.elao.run -> config:
74+
User app - Host *.elao.run:
75+
ForwardAgent yes - User: app
76+
- ForwardAgent: true
77+
```
78+
79+
- suppression dans les tâches d'integration
80+
```
81+
env:
82+
DATABASE_URL: mysql://root@127.0.0.1:3306/app
83+
```
84+
ou
85+
```
86+
env:
87+
APP_DATABASE_HOST: 127.0.0.1
88+
APP_DATABASE_NAME: api
89+
APP_DATABASE_USER: root
90+
```
91+
92+
- Bascule de `ansible/group_vars/app.yml` vers `.manala.yaml`
93+
- timezone si différente de "Etc/UTC"
94+
- Files
95+
avant:
96+
```
97+
files_attributes:
98+
- path: "{{ app.dir }}{{ app.dir_release }}/var/log"
99+
src: "{{ app.log_dir }}"
100+
state: link_directory
101+
- path: "{{ app.dir }}{{ app.dir_release }}/var/cache"
102+
src: "{{ app.cache_dir }}"
103+
state: link_directory
104+
```
105+
après:
106+
```
107+
files:
108+
- path: /srv/app/var/log
109+
src: /srv/log
110+
state: link_directory
111+
force: true
112+
- path: /srv/app/var/cache
113+
src: /srv/cache
114+
state: link_directory
115+
force: true
116+
```
117+
- Penser à rajouter l'extention php `mysql` si necessaire
118+
- apt -> supprimer package "pv" au besoin, il est maintenant intégré de base dans la vm
119+
- cron -> ne plus préciser le user, il est posé par défaut à vagrant dans system.yaml
120+
121+
- Suppression du repertoire ansible

TODO.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- deprecation des templates packer
2+
- déprécation du role zsh (il ne fait rien d'autre que d'installer) au profit d'un simple apt zsh
3+
OU déplacement de la gestion des env DANS le role zsh
4+
- deprecation du role make ???
5+
- deprecation du role npm ?
6+
- état des lieux pour ntp, envisager deprecation
7+
- templates j2 dans les roles
8+
- deprecation role/package opcache-dashboard
9+
- deprecation du role/package phpmyadmin
10+
- deprecation du role/package phpredisadmin
11+
- `manala.update: true` en dev, ou pas ???
12+
- deprecation de role/package phantomjs
13+
- penser coté jenkins à supprimer le check sur .manala/jenkins/Jenkinsfile ET à repercuter cogé config sur kubernetes
14+
- zut, et quid du app_local.yml ???
15+
- pour le local, ca pourrait se limiter aux variables d'env
16+
cf. https://blackfire.io/docs/configuration/agent#configuring-the-agent-via-environment-variables
17+
et pour le xdebug
18+
- motd dynamique

elao.app/.manala.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ system:
109109
docker:
110110
# @schema {"items": {"type": "object"}}
111111
containers: []
112+
# @schema {"items": {"type": "object"}}
113+
applications: []
112114

113115
###############
114116
# Integration #

elao.app/.manala/Dockerfile.tmpl

+11-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ RUN \
3434
&& mkdir -p /srv \
3535
&& chmod 777 /srv \
3636
# User
37-
&& adduser --disabled-password --gecos "" docker \
37+
&& addgroup --system docker \
38+
&& adduser --disabled-password --ingroup docker --gecos docker docker \
3839
# Bash
3940
&& sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' \
4041
/home/docker/.bashrc \
@@ -59,10 +60,6 @@ RUN \
5960
ansible python3 python3-apt
6061
{{- end }}
6162

62-
COPY docker/bin/entrypoint.sh /usr/local/bin/entrypoint.sh
63-
64-
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
65-
6663
##########
6764
# System #
6865
##########
@@ -73,20 +70,25 @@ COPY ansible/templates /tmp/ansible/templates/
7370
COPY ansible/ansible.cfg ansible/system.yaml /tmp/ansible/
7471

7572
RUN \
73+
# Ansible
7674
cd /tmp/ansible \
7775
&& ansible-galaxy collection install \
7876
--requirements-file roles/system/requirements.yaml \
7977
--force \
8078
&& ansible-playbook system.yaml \
8179
--inventory-file inventories \
8280
--limit integration \
83-
&& rm -Rf /tmp/ansible
84-
85-
RUN \
81+
&& rm -Rf /tmp/ansible \
82+
# Cleanup docker
83+
&& rm -Rf /var/lib/docker \
8684
# NodeJs
87-
mkdir -p /usr/etc \
85+
&& mkdir -p /usr/etc \
8886
&& echo "cache=\${XDG_CACHE_HOME}/npm" > /usr/etc/npmrc
8987

88+
COPY docker/bin/entrypoint.sh /usr/local/bin/entrypoint.sh
89+
90+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
91+
9092
WORKDIR /srv/app
9193

9294
USER docker

elao.app/.manala/Jenkinsfile.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ podTemplate(
289289
}
290290

291291
try {
292-
appImage.inside("--network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
292+
appImage.inside("--privileged --network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
293293
{{- include "node" (dict "node" $integration) | trim | nindent 16 }}
294294
}
295295
} finally {

elao.app/.manala/ansible/inventories/system.yaml.tmpl

+47-40
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ system:
88
###############
99

1010
development:
11+
1112
# Ansible
1213
ansible_connection: local
14+
1315
# Accounts
1416
manala_accounts_enabled: true
17+
manala_accounts_groups:
18+
- group: docker
19+
system: true
20+
manala_accounts_users:
21+
- user: vagrant
22+
group: vagrant
23+
groups: ['docker']
1524
# Motd
1625
manala_motd_enabled: true
1726
# Timezone
@@ -73,7 +82,38 @@ system:
7382
# Elasticsearch
7483
manala_elasticsearch_enabled: {{ not (empty .elasticsearch.version) | ternary "true" "false" }}
7584
# Docker
76-
manala_docker_enabled: true
85+
manala_docker_containers:
86+
- name: mailhog
87+
image: mailhog/mailhog:v1.0.1
88+
state: started
89+
restart_policy: unless-stopped
90+
ports:
91+
- 25:1025
92+
- 8025:8025
93+
- name: phpmyadmin
94+
image: phpmyadmin/phpmyadmin
95+
state: {{ or (not (empty .mysql.version)) (not (empty .mariadb.version)) | ternary "started" "absent" }}
96+
restart_policy: unless-stopped
97+
env:
98+
PMA_USER: root
99+
# Default docker host ip
100+
PMA_HOST: 172.17.0.1
101+
UPLOAD_LIMIT: 64M
102+
ports:
103+
- 1979:80
104+
- name: phpredisadmin
105+
image: erikdubbelboer/phpredisadmin
106+
state: {{ not (empty .redis.version) | ternary "started" "absent" }}
107+
restart_policy: unless-stopped
108+
env:
109+
# Default docker host ip
110+
REDIS_1_HOST: 172.17.0.1
111+
ports:
112+
- 1981:80
113+
{{- if .docker.containers }}
114+
# App
115+
{{- .docker.containers | toYaml | nindent 10 }}
116+
{{- end }}
77117
# Gomplate
78118
manala_gomplate_enabled: true
79119

@@ -82,8 +122,10 @@ system:
82122
###############
83123

84124
integration:
125+
85126
# Ansible
86127
ansible_connection: local
128+
87129
# Apt
88130
manala_apt_enabled: true
89131
manala_apt_packages:
@@ -120,15 +162,6 @@ system:
120162
# All #
121163
#######
122164

123-
# Accounts
124-
manala_accounts_groups:
125-
- group: docker
126-
system: true
127-
manala_accounts_users:
128-
- user: vagrant
129-
group: vagrant
130-
groups: ['docker']
131-
132165
# Motd
133166
manala_motd_scripts_exclusive: true
134167
manala_motd_scripts:
@@ -423,37 +456,11 @@ system:
423456
{{- end }}
424457

425458
# Docker
426-
manala_docker_containers:
427-
- name: mailhog
428-
image: mailhog/mailhog:v1.0.1
429-
state: started
430-
restart_policy: unless-stopped
431-
ports:
432-
- 25:1025
433-
- 8025:8025
434-
- name: phpmyadmin
435-
image: phpmyadmin/phpmyadmin
436-
state: {{ or (not (empty .mysql.version)) (not (empty .mariadb.version)) | ternary "started" "absent" }}
437-
restart_policy: unless-stopped
438-
env:
439-
PMA_USER: root
440-
# Default docker host ip
441-
PMA_HOST: 172.17.0.1
442-
UPLOAD_LIMIT: 64M
443-
ports:
444-
- 1979:80
445-
- name: phpredisadmin
446-
image: erikdubbelboer/phpredisadmin
447-
state: {{ not (empty .redis.version) | ternary "started" "absent" }}
448-
restart_policy: unless-stopped
449-
env:
450-
# Default docker host ip
451-
REDIS_1_HOST: 172.17.0.1
452-
ports:
453-
- 1981:80
454-
{{- if .docker.containers }}
459+
manala_docker_enabled: true
460+
{{- if .docker.applications }}
461+
manala_docker_applications:
455462
# App
456-
{{- .docker.containers | toYaml | nindent 10 }}
463+
{{- .docker.applications | toYaml | nindent 10 }}
457464
{{- end }}
458465

459466
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
docker run \
4+
--rm \
5+
--user 1000 \
6+
--volume /srv:/srv \
7+
elao/audiowaveform:{{ item.version|mandatory }} \
8+
"$@"

elao.app/.manala/docker/bin/entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
set -e
44

5+
# Docker
6+
sudo /etc/init.d/docker start
7+
58
# Cache (Composer and Yarn both follows XDG Base Directory Specification. For
69
# the others, related environment variables must be expanded at runtime)
710
if [ -n "${XDG_CACHE_HOME}" ]; then

elao.app/.manala/docker/make.mk.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ define docker_run
2525
--rm \
2626
--tty \
2727
--interactive \
28+
--privileged \
2829
--hostname {{ .Vars.system.hostname }} \
2930
--mount 'type=bind,consistency=delegated,source=$(realpath $(_ROOT_DIR)),target=/srv/app' \
3031
--workdir /srv/app/$(_DIR) \

elao.app/.manala/jenkins/Jenkinsfile.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ podTemplate(
289289
}
290290

291291
try {
292-
appImage.inside("--network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
292+
appImage.inside("--privileged --network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
293293
{{- include "node" (dict "node" $integration) | trim | nindent 16 }}
294294
}
295295
} finally {

0 commit comments

Comments
 (0)