Skip to content
Snippets Groups Projects
Commit 844a39a3 authored by jurgenhaas's avatar jurgenhaas
Browse files

composer/library/docker-traefik#6 Update traefik config to version 2

parent feb99e2c
No related branches found
Tags v3.1.0
No related merge requests found
...@@ -12,3 +12,7 @@ commands: ...@@ -12,3 +12,7 @@ commands:
imports: imports:
- ahoy.debug.yml - ahoy.debug.yml
usage: PHP debugging usage: PHP debugging
traefik:
imports:
- ahoy.traefik.yml
usage: Traefik commands
ahoyapi: v2
commands:
rewrite:
cmd: composer lakedrops:traefik:rewrite
usage: Pull files and DB from live site
...@@ -14,6 +14,7 @@ class CommandProvider implements CommandProviderCapability { ...@@ -14,6 +14,7 @@ class CommandProvider implements CommandProviderCapability {
*/ */
public function getCommands(): array { public function getCommands(): array {
return [ return [
new TraefikRewriteCommand(),
new UpdateCommand(), new UpdateCommand(),
]; ];
} }
......
...@@ -272,6 +272,31 @@ class Handler extends BaseHandler { ...@@ -272,6 +272,31 @@ class Handler extends BaseHandler {
$this->gitIgnore('tests/backstop/backstop_data/html_report'); $this->gitIgnore('tests/backstop/backstop_data/html_report');
$this->gitLFS('tests/backstop/**/*.png'); $this->gitLFS('tests/backstop/**/*.png');
$this->updateTraefik(FALSE);
// Set permissions, see https://wodby.com/stacks/drupal/docs/local/permissions
exec('setfacl -dR -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX -m g::rwX ' . $projectRoot . ' >/dev/null 2>&1');
exec('setfacl -R -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX -m g::rwX ' . $projectRoot . ' >/dev/null 2>&1');
}
/**
* Configure Traefik on the host for all projects.
*
* @param bool $rewrite
* Whether to rewrite existing Traefik config.
*/
public function configureTraefik($rewrite = FALSE): void {
if (!$this->isDevMode()) {
return;
}
$this->init();
$this->updateTraefik($rewrite);
}
/**
* @param $rewrite
*/
private function updateTraefik($rewrite): void {
$traefik = new Traefik( $traefik = new Traefik(
$this->config->readValue('projectname'), $this->config->readValue('projectname'),
$this->config->readValue(['traefik', 'domain']), $this->config->readValue(['traefik', 'domain']),
...@@ -280,11 +305,7 @@ class Handler extends BaseHandler { ...@@ -280,11 +305,7 @@ class Handler extends BaseHandler {
$this->config->readValue(['traefik', 'cert']), $this->config->readValue(['traefik', 'cert']),
$this->config->readValue(['traefik', 'key']) $this->config->readValue(['traefik', 'key'])
); );
$traefik->update(); $traefik->update($rewrite);
// Set permissions, see https://wodby.com/stacks/drupal/docs/local/permissions
exec('setfacl -dR -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX -m g::rwX ' . $projectRoot . ' >/dev/null 2>&1');
exec('setfacl -R -m u:$(whoami):rwX -m u:82:rwX -m u:100:rX -m g::rwX ' . $projectRoot . ' >/dev/null 2>&1');
} }
/** /**
...@@ -378,6 +399,8 @@ class Handler extends BaseHandler { ...@@ -378,6 +399,8 @@ class Handler extends BaseHandler {
} }
/** /**
* @param string $projectname
*
* @return string * @return string
*/ */
private function getDockerProxy(string $projectname): string { private function getDockerProxy(string $projectname): string {
......
<?php
namespace LakeDrops\Docker4Drupal;
use LakeDrops\Component\Composer\BaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TraefikRewriteCommand extends BaseCommand {
/**
* {@inheritdoc}
*/
protected function configure() {
$this->setName('lakedrops:traefik:rewrite');
$this->setDescription('Rewrite Traefik config on this host.');
}
/**
* {@inheritdoc}
*/
public function getHandlerClass(): string {
return Handler::class;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
parent::execute($input, $output);
/** @var Handler $handler */
$handler = $this->handler;
$handler->configureTraefik(TRUE);
return 0;
}
}
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace LakeDrops\Docker4Drupal; namespace LakeDrops\Docker4Drupal;
use LakeDrops\Component\Composer\BaseCommand; use LakeDrops\Component\Composer\BaseCommand;
use LakeDrops\Component\Composer\BaseHandlerInterface;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
...@@ -26,10 +25,6 @@ class UpdateCommand extends BaseCommand { ...@@ -26,10 +25,6 @@ class UpdateCommand extends BaseCommand {
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/ */
protected function execute(InputInterface $input, OutputInterface $output): int { protected function execute(InputInterface $input, OutputInterface $output): int {
parent::execute($input, $output); parent::execute($input, $output);
......
...@@ -82,8 +82,7 @@ services: ...@@ -82,8 +82,7 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`{{ projectname }}.{{ traefik.domain }}`) traefik.http.routers.{{ projectname }}_{{ webserver.type }}.rule: Host(`{{ projectname }}.{{ traefik.domain }}`){% for domain in extradomains|default([]) %} || Host(`{{ domain }}`){% endfor %}'
#{% for domain in extradomains|default([]) %},{{ domain }}{% endfor %}'
{% if varnish.enable %} {% if varnish.enable %}
varnish: varnish:
...@@ -97,7 +96,7 @@ services: ...@@ -97,7 +96,7 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`varnish.{{ projectname }}.{{ traefik.domain }}`) traefik.http.routers.{{ projectname }}_varnish.rule: Host(`varnish-{{ projectname }}.{{ traefik.domain }}`)
{% endif %} {% endif %}
redis: redis:
...@@ -111,8 +110,8 @@ services: ...@@ -111,8 +110,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`adminer.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_adminer.loadbalancer.server.port: 9000
#traefik.port: '9000' traefik.http.routers.{{ projectname }}_adminer.rule: Host(`adminer-{{ projectname }}.{{ traefik.domain }}`)
{% elseif dbbrowser.type == 'pma' %} {% elseif dbbrowser.type == 'pma' %}
pma: pma:
image: 'phpmyadmin/phpmyadmin:5' image: 'phpmyadmin/phpmyadmin:5'
...@@ -125,7 +124,7 @@ services: ...@@ -125,7 +124,7 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`pma.{{ projectname }}.{{ traefik.domain }}`) traefik.http.routers.{{ projectname }}_pma.rule: Host(`pma-{{ projectname }}.{{ traefik.domain }}`)
{% endif %} {% endif %}
{% if solr.enable %} {% if solr.enable %}
...@@ -136,8 +135,8 @@ services: ...@@ -136,8 +135,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`solr.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_solr.loadbalancer.server.port: 8983
#traefik.port: '8983' traefik.http.routers.{{ projectname }}_solr.rule: Host(`solr-{{ projectname }}.{{ traefik.domain }}`)
{% endif %} {% endif %}
mailhog: mailhog:
...@@ -145,8 +144,8 @@ services: ...@@ -145,8 +144,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`mailhog.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_mailhog.loadbalancer.server.port: 8025
#traefik.port: '8025' traefik.http.routers.{{ projectname }}_mailhog.rule: Host(`mailhog-{{ projectname }}.{{ traefik.domain }}`)
{% if node.enable %} {% if node.enable %}
nodejs: nodejs:
...@@ -156,8 +155,8 @@ services: ...@@ -156,8 +155,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`nodejs.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_nodejs.loadbalancer.server.port: 8080
#traefik.port: '8080' traefik.http.routers.{{ projectname }}_nodejs.rule: Host(`nodejs-{{ projectname }}.{{ traefik.domain }}`)
volumes: volumes:
- {{ projectroot }}/{{ node.path }}:/app - {{ projectroot }}/{{ node.path }}:/app
command: sh -c 'npm install && npm run start' command: sh -c 'npm install && npm run start'
...@@ -168,8 +167,8 @@ services: ...@@ -168,8 +167,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`front.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_node.loadbalancer.server.port: 3000
#traefik.port: '3000' traefik.http.routers.{{ projectname }}_node.rule: Host(`front-{{ projectname }}.{{ traefik.domain }}`)
expose: expose:
- '3000' - '3000'
volumes: volumes:
...@@ -216,8 +215,8 @@ services: ...@@ -216,8 +215,8 @@ services:
labels: labels:
traefik.enable: true traefik.enable: true
traefik.network: {{ projectname }} traefik.network: {{ projectname }}
traefik.http.routers.whoami.rule: Host(`webgrind.{{ projectname }}.{{ traefik.domain }}`) traefik.http.services.{{ projectname }}_webgrind.loadbalancer.server.port: 8080
#traefik.port: '8080' traefik.http.routers.{{ projectname }}_webgrind.rule: Host(`webgrind-{{ projectname }}.{{ traefik.domain }}`)
volumes: volumes:
- {{ projectroot }}/files:/mnt/files - {{ projectroot }}/files:/mnt/files
{% endif %} {% endif %}
......
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