Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Traefik
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Composer
library
Traefik
Commits
99a5647c
Commit
99a5647c
authored
3 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
composer/plugin/docker4drupal#48
Improve setup to only work on a single network traefik-public
Update Traefik to 2.6 Update Portainer to 2.11.1
parent
b0a4f22c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Traefik.php
+17
-29
17 additions, 29 deletions
Traefik.php
with
17 additions
and
29 deletions
Traefik.php
+
17
−
29
View file @
99a5647c
...
@@ -84,23 +84,17 @@ class Traefik {
...
@@ -84,23 +84,17 @@ class Traefik {
/**
/**
* Update the Traefik container.
* Update the Traefik container.
*
* @param bool $rewrite
*/
*/
public
function
update
(
$rewrite
=
FALSE
):
void
{
public
function
update
():
void
{
// Update host wide
r
traefik container.
// Update host wide traefik container.
$traefikPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik'
;
$traefikPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik'
;
$traefikCertPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik/certs'
;
$traefikCertPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik/certs'
;
$traefikConfigPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik/configuration'
;
$traefikConfigPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik/configuration'
;
$traefikFile
=
$traefikPath
.
'/docker-compose.yml'
;
$traefikFile
=
$traefikPath
.
'/docker-compose.yml'
;
$fs
=
new
Filesystem
();
$fs
=
new
Filesystem
();
if
(
!
$rewrite
&&
$fs
->
exists
(
$traefikFile
))
{
if
(
!
$fs
->
exists
(
$traefikPath
))
{
$traefik
=
Yaml
::
parse
(
file_get_contents
(
$traefikFile
));
}
else
{
$fs
->
mkdir
(
$traefikPath
);
$fs
->
mkdir
(
$traefikPath
);
$traefik
=
$this
->
defaultDockerCompose
();
}
}
if
(
!
$fs
->
exists
(
$traefikCertPath
))
{
if
(
!
$fs
->
exists
(
$traefikCertPath
))
{
$fs
->
mkdir
(
$traefikCertPath
);
$fs
->
mkdir
(
$traefikCertPath
);
...
@@ -109,18 +103,12 @@ class Traefik {
...
@@ -109,18 +103,12 @@ class Traefik {
$fs
->
mkdir
(
$traefikConfigPath
);
$fs
->
mkdir
(
$traefikConfigPath
);
}
}
file_put_contents
(
$traefikConfigPath
.
'/certificates.toml'
,
$this
->
defaultCertificatesConfig
());
file_put_contents
(
$traefikConfigPath
.
'/certificates.toml'
,
$this
->
defaultCertificatesConfig
());
file_put_contents
(
$traefikFile
,
Yaml
::
dump
(
$this
->
defaultDockerCompose
(),
9
,
2
));
if
(
!
in_array
(
$this
->
name
,
$traefik
[
'services'
][
'traefik'
][
'networks'
],
TRUE
))
{
$cwd
=
getcwd
();
$traefik
[
'services'
][
'traefik'
][
'networks'
][]
=
$this
->
name
;
chdir
(
$traefikPath
);
$traefik
[
'networks'
][
$this
->
name
]
=
[
exec
(
'docker network create traefik-public 2>/dev/null'
);
'driver'
=>
'bridge'
,
exec
(
'docker compose --project-name traefik up -d'
);
];
chdir
(
$cwd
);
file_put_contents
(
$traefikFile
,
Yaml
::
dump
(
$traefik
,
9
,
2
));
$cwd
=
getcwd
();
chdir
(
$traefikPath
);
exec
(
'docker compose --project-name traefik up -d'
);
chdir
(
$cwd
);
}
}
}
/**
/**
...
@@ -131,7 +119,7 @@ class Traefik {
...
@@ -131,7 +119,7 @@ class Traefik {
'version'
=>
'3.3'
,
'version'
=>
'3.3'
,
'services'
=>
[
'services'
=>
[
'traefik'
=>
[
'traefik'
=>
[
'image'
=>
'traefik:
v
2.
3
'
,
'image'
=>
'traefik:2.
6
'
,
'command'
=>
[
'command'
=>
[
'--api=true'
,
'--api=true'
,
'--api.dashboard=true'
,
'--api.dashboard=true'
,
...
@@ -147,7 +135,7 @@ class Traefik {
...
@@ -147,7 +135,7 @@ class Traefik {
],
],
'restart'
=>
'unless-stopped'
,
'restart'
=>
'unless-stopped'
,
'networks'
=>
[
'networks'
=>
[
'
internal
'
,
'
traefik-public
'
,
],
],
'ports'
=>
[
'ports'
=>
[
$this
->
http_port
.
':80'
,
$this
->
http_port
.
':80'
,
...
@@ -155,7 +143,7 @@ class Traefik {
...
@@ -155,7 +143,7 @@ class Traefik {
],
],
'labels'
=>
[
'labels'
=>
[
'traefik.enable=true'
,
'traefik.enable=true'
,
'traefik.network=
internal
'
,
'traefik.network=
traefik-public
'
,
'traefik.http.routers.traefik.service=api@internal'
,
'traefik.http.routers.traefik.service=api@internal'
,
'traefik.http.routers.traefik.rule=Host(`traefik.'
.
$this
->
domain
.
'`)'
,
'traefik.http.routers.traefik.rule=Host(`traefik.'
.
$this
->
domain
.
'`)'
,
],
],
...
@@ -167,22 +155,22 @@ class Traefik {
...
@@ -167,22 +155,22 @@ class Traefik {
],
],
],
],
'networks'
=>
[
'networks'
=>
[
'
internal
'
=>
[
'
traefik-public
'
=>
[
'
in
ternal'
=>
true
,
'
ex
ternal'
=>
true
,
],
],
],
],
];
];
if
(
$this
->
addon_portainer
)
{
if
(
$this
->
addon_portainer
)
{
$config
[
'services'
][
'portainer'
]
=
[
$config
[
'services'
][
'portainer'
]
=
[
'image'
=>
'portainer/portainer-ce:2.
0.0
'
,
'image'
=>
'portainer/portainer-ce:2.
11.1
'
,
'command'
=>
'-H unix:///var/run/docker.sock'
,
'command'
=>
'-H unix:///var/run/docker.sock'
,
'restart'
=>
'unless-stopped'
,
'restart'
=>
'unless-stopped'
,
'networks'
=>
[
'networks'
=>
[
'
internal
'
,
'
traefik-public
'
,
],
],
'labels'
=>
[
'labels'
=>
[
'traefik.enable=true'
,
'traefik.enable=true'
,
'traefik.network=
internal
'
,
'traefik.network=
traefik-public
'
,
'traefik.http.routers.frontend.rule=Host(`portainer.'
.
$this
->
domain
.
'`)'
,
'traefik.http.routers.frontend.rule=Host(`portainer.'
.
$this
->
domain
.
'`)'
,
'traefik.http.routers.frontend.entrypoints=websecure'
,
'traefik.http.routers.frontend.entrypoints=websecure'
,
'traefik.http.services.frontend.loadbalancer.server.port=9000'
,
'traefik.http.services.frontend.loadbalancer.server.port=9000'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment