Skip to content
Snippets Groups Projects
Commit 5faebaf4 authored by jurgenhaas's avatar jurgenhaas
Browse files
- add support for crontabs in NG context
parent cfad2af9
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,9 @@ class Handler extends BaseHandler { ...@@ -153,6 +153,9 @@ class Handler extends BaseHandler {
'enable' => 0, 'enable' => 0,
], ],
'backstop' => $this->backstopDefaults(), 'backstop' => $this->backstopDefaults(),
'crontabs' => [
'www-data' => [],
]
]; ];
if ($this->isCiContext() || $this->isLocalDevMode()) { if ($this->isCiContext() || $this->isLocalDevMode()) {
...@@ -297,7 +300,13 @@ class Handler extends BaseHandler { ...@@ -297,7 +300,13 @@ class Handler extends BaseHandler {
$filename = $this->config->render($template, $template); $filename = $this->config->render($template, $template);
$file = $def['dest'] . '/' . $filename; $file = $def['dest'] . '/' . $filename;
if (($overwrite && empty($def['add2git'])) || !$fs->exists($file)) { if (($overwrite && empty($def['add2git'])) || !$fs->exists($file)) {
$rendered = $this->config->render($filename, file_get_contents($pluginRoot . '/templates/' . ($def['source'] ?? '') . $template . '.twig')); $source = isset($def['source']) && is_file($pluginRoot . '/templates/' . $def['source']) ?
$pluginRoot . '/templates/' . $def['source'] :
$pluginRoot . '/templates/' . ($def['source'] ?? '') . $template . '.twig';
if (isset($def['options'])) {
$this->config->setValue('loopoptions', $def['options'], FALSE);
}
$rendered = $this->config->render($filename, file_get_contents($source));
$extraOptions = $this->config->readValue($filename); $extraOptions = $this->config->readValue($filename);
if (!empty($def['add2yaml']) && $extraOptions !== NULL) { if (!empty($def['add2yaml']) && $extraOptions !== NULL) {
$yaml = Yaml::parse($rendered); $yaml = Yaml::parse($rendered);
...@@ -409,7 +418,7 @@ class Handler extends BaseHandler { ...@@ -409,7 +418,7 @@ class Handler extends BaseHandler {
* List of files. * List of files.
*/ */
protected function getFiles(string $projectRoot, string $webRoot, string $settingsPath): array { protected function getFiles(string $projectRoot, string $webRoot, string $settingsPath): array {
return [ $files = [
'settings.docker.php' => [ 'settings.docker.php' => [
'dest' => $projectRoot . '/' . $settingsPath, 'dest' => $projectRoot . '/' . $settingsPath,
'link' => $webRoot . '/sites/default', 'link' => $webRoot . '/sites/default',
...@@ -461,6 +470,16 @@ class Handler extends BaseHandler { ...@@ -461,6 +470,16 @@ class Handler extends BaseHandler {
'dest' => $projectRoot . '/tests', 'dest' => $projectRoot . '/tests',
], ],
]; ];
if (getenv('LAKEDROPS_BUILD_NG') === 'yes') {
foreach ($this->config->readValue('crontabs') ?? [] as $user => $tasks) {
$files[$user] = [
'source' => 'crontabs/template.twig',
'dest' => $projectRoot . '/crontabs',
'options' => $tasks,
];
}
}
return $files;
} }
/** /**
......
{% for line in loopoptions|default([]) %}
{{ line|raw }}
{% endfor %}
...@@ -93,6 +93,34 @@ services: ...@@ -93,6 +93,34 @@ services:
{% endif %} {% endif %}
extra_hosts: extra_hosts:
- '{{ projectdomain }}:{{ docker0.ip }}' - '{{ projectdomain }}:{{ docker0.ip }}'
{% if drupal.live|default(0) %}
cron:
image: 'wodby/drupal-php:{{ php.version }}'
restart: unless-stopped
environment:
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
DB_HOST: mariadb
DB_USER: drupal
DB_PASSWORD: drupal
DB_NAME: drupal
DB_DRIVER: mysql
COMPOSER_ALLOW_SUPERUSER: 1
{% if php.ssh and not drupal.live|default(0) %}
SSH_AUTH_SOCK: /ssh-agent
{% endif %}
volumes:
- {{ projectroot }}:/var/www/html
- {{ projectroot }}/drush:/etc/drush
- {{ projectrootfiles }}:/data/default
- {{ projectroot }}/crontabs:/etc/crontabs
{% if php.ssh and not drupal.live|default(0) %}
- {{ php.ssh_auth_sock }}:/ssh-agent
{% endif %}
extra_hosts:
- '{{ projectdomain }}:{{ docker0.ip }}'
{% endif %}
command: sudo -E crond -f -d 0
{{ webserver.type }}: {{ webserver.type }}:
image: {% if webserver.type == 'nginx' %}'wodby/drupal-nginx:{{ webserver.version|default("1.21") }}'{% elseif webserver.type == 'apache' %}'wodby/apache:2.4'{% endif %} image: {% if webserver.type == 'nginx' %}'wodby/drupal-nginx:{{ webserver.version|default("1.21") }}'{% elseif webserver.type == 'apache' %}'wodby/apache:2.4'{% endif %}
...@@ -134,6 +162,7 @@ services: ...@@ -134,6 +162,7 @@ services:
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.middlewares: {{ webserver.type }}-{{ projectname }}-auth@docker traefik.http.routers.{{ webserver.type }}-{{ projectname }}.middlewares: {{ webserver.type }}-{{ projectname }}-auth@docker
{% endif %} {% endif %}
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.rule: Host(`{{ projectdomain }}`){% for domain in extradomains|default([]) %} || Host(`{{ domain }}`){% endfor %} traefik.http.routers.{{ webserver.type }}-{{ projectname }}.rule: Host(`{{ projectdomain }}`){% for domain in extradomains|default([]) %} || Host(`{{ domain }}`){% endfor %}
{% if drupal.live|default(0) %} {% if drupal.live|default(0) %}
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.tls: 'true' traefik.http.routers.{{ webserver.type }}-{{ projectname }}.tls: 'true'
traefik.http.routers.{{ webserver.type }}-{{ projectname }}.tls.certresolver: lakedrops traefik.http.routers.{{ webserver.type }}-{{ projectname }}.tls.certresolver: lakedrops
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment