Skip to content

Commit

Permalink
[Elao - App - Docker] Switch to systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
nervo committed Dec 15, 2023
1 parent 7d1fa65 commit 30fbebb
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion elao.app.docker/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ system:
network:
hosts: {}
goss:
# @schema {"enum": [null, "0.3.21"]}
# @schema {"enum": [null, "0.4.4"]}
version: ~
nginx:
# @schema {
Expand Down
2 changes: 1 addition & 1 deletion elao.app.docker/.manala/Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MANALA_DOCKER_COMPOSE_ENV += \
MANALA_HOST_OS=$(MANALA_OS) \
MANALA_HOST_DIR=$(abspath $(MANALA_DIR))
MANALA_DOCKER_COMPOSE_FILE += \
$(MANALA_DIR)/.manala/docker/compose/init.sysv.yaml \
$(MANALA_DIR)/.manala/docker/compose/init.systemd.yaml \
$(if $(SYMFONY_IDE), $(MANALA_DIR)/.manala/docker/compose/symfony.yaml)
MANALA_DOCKER_COMPOSE_PROFILE ?= development

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

collections:
- ansible.posix
- community.crypto
- community.docker
- community.general
- community.mongodb
- community.mysql
- gluster.gluster
- manala.roles
- community.crypto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- ["{{ certificates_ssl_pem }}", certs]
- ["{{ certificates_ssl_key }}", private]
notify:
- nginx restart
- Restart nginx
when: (certificates_ssl_key is file)
and (certificates_ssl_pem is file)

Expand All @@ -86,7 +86,7 @@
type: RSA
size: 4096
notify:
- nginx restart
- Restart nginx
- name: certificates > Generate self signed ssl certificate signing request
community.crypto.openssl_csr:
path: /etc/ssl/certs/ssl.csr
Expand All @@ -102,6 +102,6 @@
privatekey_path: /etc/ssl/private/ssl.key
provider: selfsigned
notify:
- nginx restart
- Restart nginx
when: (certificates_ssl_key is not file)
or (certificates_ssl_pem is not file)
19 changes: 11 additions & 8 deletions elao.app.docker/.manala/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RUN \
fi \
{{- end }}
# Apt keyrings (debian < bookworm)
&& mkdir --verbose --parents /etc/apt/keyrings \
&& install --verbose --mode 0755 --directory /etc/apt/keyrings \
# User
&& addgroup --gid ${MANALA_GROUP_ID} app \
&& adduser --home /home/app --shell /bin/bash --uid ${MANALA_USER_ID} --gecos app --ingroup app --disabled-password app \
Expand Down Expand Up @@ -130,7 +130,8 @@ RUN \
umountfs \
umountroot \
# Block systemd replacement
&& printf "Package: systemd-sysv\n\
&& printf "\
Package: systemd-sysv\n\
Pin: release *\n\
Pin-Priority: -1\n\
" > /etc/apt/preferences \
Expand Down Expand Up @@ -170,21 +171,22 @@ RUN \
&& systemctl set-default multi-user.target \
&& sed -i 's/#\(ForwardToConsole=\).*$/\1yes/' \
/etc/systemd/journald.conf \
&& printf "Defaults env_keep += \"container\"\n" \
&& echo "Defaults env_keep += \"container\"" \
> /etc/sudoers.d/systemd \
&& rm -rf \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/multi-user.target.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev* \
/lib/systemd/system/systemd-ask-password-console.* \
/lib/systemd/system/systemd-tmpfiles-clean.* \
/lib/systemd/system/systemd-update-utmp* \
# Clean
&& rm -rf /var/lib/apt/lists/*

VOLUME /sys/fs/cgroup

STOPSIGNAL SIGRTMIN+3

CMD ["/lib/systemd/systemd"]
Expand All @@ -201,7 +203,7 @@ FROM init-${MANALA_INIT} AS provision-none
# Ansible
FROM init-${MANALA_INIT} AS provision-ansible

ARG ANSIBLE_VERSION="8.5.0"
ARG ANSIBLE_VERSION="8.7.0"
ARG MANALA_PROVISION_LIMIT
ARG SYMFONY_IDE

Expand Down Expand Up @@ -229,8 +231,9 @@ RUN \
&& pip3 --no-cache-dir --disable-pip-version-check install \
ansible==${ANSIBLE_VERSION} \
{{- end }}
&& mkdir --verbose --parents /etc/ansible \
&& printf "[defaults]\n\
&& install --verbose --mode 0755 --directory /etc/ansible \
&& printf "\
[defaults]\n\
force_color = True\n\
display_skipped_hosts = False\n\
retry_files_enabled = False\n\
Expand Down
5 changes: 4 additions & 1 deletion elao.app.docker/.manala/docker/compose/init.systemd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ services:
build:
args:
MANALA_INIT: systemd
cgroup: host
tty: true
privileged: true
tmpfs:
- /run
- /run/lock
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
8 changes: 5 additions & 3 deletions elao.app.docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ tableOfContent: 3

MacOS

* Docker Desktop 4.3.2+
* Docker Desktop 4.25.2+
(`brew install docker`)
* Mutagen Compose 0.13.0+
* Mutagen Compose 0.18.0+
(`brew install mutagen-io/mutagen/mutagen-compose`)

Linux

* Docker 20.10.14+
* Docker Engine 24.0.6+
(see [documentation](https://docs.docker.com/engine/install/))
* Compose 2.23.0+
(see [documentation](https://docs.docker.com/compose/install/))

## Overview

Expand Down
2 changes: 1 addition & 1 deletion elao.app.docker/test/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ system:
hosts:
1.2.3.4: foo.bar
goss:
version: 0.3.21
version: 0.4.4
nginx:
configs:
- template: nginx/gzip.j2
Expand Down
18 changes: 9 additions & 9 deletions elao.app.docker/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ command:
ansible --version:
exit-status: 0
stdout:
- ansible [core 2.15.5]
- ansible [core 2.15.8]
# Locales
locale:
exit-status: 0
Expand Down Expand Up @@ -110,35 +110,35 @@ file:
# System
/etc/os-release:
exists: true
contains:
contents:
- VERSION_ID="{{ .Vars.system.version }}"
# Timezone
/etc/timezone:
exists: true
contains:
contents:
- {{ .Vars.system.timezone }}
# Files
/srv/foo:
exists: true
contains:
contents:
- bar
# Php
/etc/php/{{ .Vars.system.php.version }}/fpm/pool.d/app.conf:
exists: true
contains:
contents:
{{- range $key, $value := .Vars.system.php.env }}
- env[{{ $key }}] = "{{ $value }}"
{{- end }}
# Cron
/etc/cron.d/app:
exists: true
contains:
contents:
- HOME="/srv/app"
- "* * * * * app php bin/console app:foo:bar --no-interaction -vv >> /srv/"
# Supervisor
/etc/supervisor/conf.d/app.conf:
exists: true
contains:
contents:
- "[program:foo]"
- autorestart=true
- autostart=false
Expand All @@ -153,8 +153,8 @@ file:
# Ssh
/etc/ssh/ssh_config:
exists: true
contains:
- # Ssh config
contents:
- "# Ssh config"

http:
# MailHog
Expand Down

0 comments on commit 30fbebb

Please sign in to comment.