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
d64f3100
Commit
d64f3100
authored
4 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#5
Make traefik configuration configurable
parent
5ff10b8e
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
+50
-4
50 additions, 4 deletions
Traefik.php
with
50 additions
and
4 deletions
Traefik.php
+
50
−
4
View file @
d64f3100
...
...
@@ -19,23 +19,64 @@ class Traefik {
*/
protected
$name
;
/**
* @var string
*/
protected
$domain
;
/**
* @var int
*/
protected
$http_port
;
/**
* @var int
*/
protected
$https_port
;
/**
* @var string
*/
protected
$cert_filename
;
/**
* @var string
*/
protected
$key_filename
;
/**
* Traefik constructor.
*
* @param string $name
* Name of the network to be created which needs to match the container
* prefix of your project you would like to handle with Traefik.
* @param string $domain
* The domain name used for all local projects.
* @param int $http_port
* Port for non secure requests.
* @param int $https_port
* Port for secure requests.
* @param string $cert_filename
* Filename of the SSL certificate.
* @param string $key_filename
* Filename of the private key for the SSL certificate.
*/
public
function
__construct
(
$name
)
{
public
function
__construct
(
string
$name
,
$domain
=
'docker.localhost'
,
$http_port
=
8000
,
$https_port
=
8443
,
$cert_filename
=
'cert.pem'
,
$key_filename
=
'key.pem'
)
{
$this
->
name
=
$name
;
$this
->
domain
=
$domain
;
$this
->
http_port
=
$http_port
;
$this
->
https_port
=
$https_port
;
$this
->
cert_filename
=
$cert_filename
;
$this
->
key_filename
=
$key_filename
;
}
/**
* Update the Traefik container.
*/
public
function
update
()
{
public
function
update
()
:
void
{
// Update host wider traefik container.
$traefikPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik'
;
$traefikCertPath
=
$_SERVER
[
'HOME'
]
.
'/.traefik/certs'
;
$traefikFile
=
$traefikPath
.
'/docker-compose.yml'
;
$fs
=
new
Filesystem
();
...
...
@@ -50,12 +91,14 @@ class Traefik {
'traefik'
=>
[
'image'
=>
'traefik:1.7.17'
,
'restart'
=>
'unless-stopped'
,
'command'
=>
'-c /dev/null --web --docker --
logLevel=DEBUG
'
,
'command'
=>
'-c /dev/null --web --docker --
defaultEntryPoints="https" --defaultEntryPoints="http" --entryPoints="Name:https Address::443 TLS:/certs/'
.
$this
->
cert_filename
.
',/certs/'
.
$this
->
key_filename
.
'" --entryPoints="Name:http Address::80"
'
,
'networks'
=>
[],
'ports'
=>
[
'8000:80'
,
$this
->
http_port
.
':80'
,
$this
->
https_port
.
':443'
,
],
'volumes'
=>
[
'./certs:/certs/'
,
'/var/run/docker.sock:/var/run/docker.sock'
,
],
],
...
...
@@ -63,6 +106,9 @@ class Traefik {
'networks'
=>
[],
];
}
if
(
!
$fs
->
exists
(
$traefikCertPath
))
{
$fs
->
mkdir
(
$traefikCertPath
);
}
if
(
!
in_array
(
$this
->
name
,
$traefik
[
'services'
][
'traefik'
][
'networks'
],
TRUE
))
{
$traefik
[
'services'
][
'traefik'
][
'networks'
][]
=
$this
->
name
;
...
...
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