Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Elao - App] Docker applications #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions elao.app/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ system:
docker:
# @schema {"items": {"type": "object"}}
containers: []
# @schema {"items": {"type": "object"}}
applications: []

###############
# Integration #
Expand Down
20 changes: 11 additions & 9 deletions elao.app/.manala/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ RUN \
&& mkdir -p /srv \
&& chmod 777 /srv \
# User
&& adduser --disabled-password --gecos "" docker \
&& addgroup --system docker \
&& adduser --disabled-password --ingroup docker --gecos docker docker \
# Bash
&& sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' \
/home/docker/.bashrc \
Expand All @@ -59,10 +60,6 @@ RUN \
ansible python3 python3-apt
{{- end }}

COPY docker/bin/entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

##########
# System #
##########
Expand All @@ -73,20 +70,25 @@ COPY ansible/templates /tmp/ansible/templates/
COPY ansible/ansible.cfg ansible/system.yaml /tmp/ansible/

RUN \
# Ansible
cd /tmp/ansible \
&& ansible-galaxy collection install \
--requirements-file roles/system/requirements.yaml \
--force \
&& ansible-playbook system.yaml \
--inventory-file inventories \
--limit integration \
&& rm -Rf /tmp/ansible

RUN \
&& rm -Rf /tmp/ansible \
# Cleanup docker
&& rm -Rf /var/lib/docker \
# NodeJs
mkdir -p /usr/etc \
&& mkdir -p /usr/etc \
&& echo "cache=\${XDG_CACHE_HOME}/npm" > /usr/etc/npmrc

COPY docker/bin/entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

WORKDIR /srv/app

USER docker
Expand Down
2 changes: 1 addition & 1 deletion elao.app/.manala/Jenkinsfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ podTemplate(
}

try {
appImage.inside("--network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
appImage.inside("--privileged --network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
{{- include "node" (dict "node" $integration) | trim | nindent 16 }}
}
} finally {
Expand Down
87 changes: 47 additions & 40 deletions elao.app/.manala/ansible/inventories/system.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ system:
###############

development:

# Ansible
ansible_connection: local

# Accounts
manala_accounts_enabled: true
manala_accounts_groups:
- group: docker
system: true
manala_accounts_users:
- user: vagrant
group: vagrant
groups: ['docker']
# Motd
manala_motd_enabled: true
# Timezone
Expand Down Expand Up @@ -73,7 +82,38 @@ system:
# Elasticsearch
manala_elasticsearch_enabled: {{ not (empty .elasticsearch.version) | ternary "true" "false" }}
# Docker
manala_docker_enabled: true
manala_docker_containers:
- name: mailhog
image: mailhog/mailhog:v1.0.1
state: started
restart_policy: unless-stopped
ports:
- 25:1025
- 8025:8025
- name: phpmyadmin
image: phpmyadmin/phpmyadmin
state: {{ or (not (empty .mysql.version)) (not (empty .mariadb.version)) | ternary "started" "absent" }}
restart_policy: unless-stopped
env:
PMA_USER: root
# Default docker host ip
PMA_HOST: 172.17.0.1
UPLOAD_LIMIT: 64M
ports:
- 1979:80
- name: phpredisadmin
image: erikdubbelboer/phpredisadmin
state: {{ not (empty .redis.version) | ternary "started" "absent" }}
restart_policy: unless-stopped
env:
# Default docker host ip
REDIS_1_HOST: 172.17.0.1
ports:
- 1981:80
{{- if .docker.containers }}
# App
{{- .docker.containers | toYaml | nindent 10 }}
{{- end }}
# Gomplate
manala_gomplate_enabled: true

Expand All @@ -82,8 +122,10 @@ system:
###############

integration:

# Ansible
ansible_connection: local

# Apt
manala_apt_enabled: true
manala_apt_packages:
Expand Down Expand Up @@ -120,15 +162,6 @@ system:
# All #
#######

# Accounts
manala_accounts_groups:
- group: docker
system: true
manala_accounts_users:
- user: vagrant
group: vagrant
groups: ['docker']

# Motd
manala_motd_scripts_exclusive: true
manala_motd_scripts:
Expand Down Expand Up @@ -423,37 +456,11 @@ system:
{{- end }}

# Docker
manala_docker_containers:
- name: mailhog
image: mailhog/mailhog:v1.0.1
state: started
restart_policy: unless-stopped
ports:
- 25:1025
- 8025:8025
- name: phpmyadmin
image: phpmyadmin/phpmyadmin
state: {{ or (not (empty .mysql.version)) (not (empty .mariadb.version)) | ternary "started" "absent" }}
restart_policy: unless-stopped
env:
PMA_USER: root
# Default docker host ip
PMA_HOST: 172.17.0.1
UPLOAD_LIMIT: 64M
ports:
- 1979:80
- name: phpredisadmin
image: erikdubbelboer/phpredisadmin
state: {{ not (empty .redis.version) | ternary "started" "absent" }}
restart_policy: unless-stopped
env:
# Default docker host ip
REDIS_1_HOST: 172.17.0.1
ports:
- 1981:80
{{- if .docker.containers }}
manala_docker_enabled: true
{{- if .docker.applications }}
manala_docker_applications:
# App
{{- .docker.containers | toYaml | nindent 10 }}
{{- .docker.applications | toYaml | nindent 10 }}
{{- end }}

{{- end }}
8 changes: 8 additions & 0 deletions elao.app/.manala/ansible/templates/docker/audiowaveform.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

docker run \
--rm \
--user 1000 \
--volume /srv:/srv \
elao/audiowaveform:{{ item.version|mandatory }} \
"$@"
3 changes: 3 additions & 0 deletions elao.app/.manala/docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -e

# Docker
sudo /etc/init.d/docker start

# Cache (Composer and Yarn both follows XDG Base Directory Specification. For
# the others, related environment variables must be expanded at runtime)
if [ -n "${XDG_CACHE_HOME}" ]; then
Expand Down
1 change: 1 addition & 0 deletions elao.app/.manala/docker/make.mk.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ define docker_run
--rm \
--tty \
--interactive \
--privileged \
--hostname {{ .Vars.system.hostname }} \
--mount 'type=bind,consistency=delegated,source=$(realpath $(_ROOT_DIR)),target=/srv/app' \
--workdir /srv/app/$(_DIR) \
Expand Down
2 changes: 1 addition & 1 deletion elao.app/.manala/jenkins/Jenkinsfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ podTemplate(
}

try {
appImage.inside("--network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
appImage.inside("--privileged --network container:${hostContainerId} --env XDG_CACHE_HOME=${appCacheHome}/app") {
{{- include "node" (dict "node" $integration) | trim | nindent 16 }}
}
} finally {
Expand Down