Skip to content

Commit d08d931

Browse files
authored
📌 Make the public Traefik network a fixed default (#150)
to simplify development
1 parent ff55b77 commit d08d931

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ The input variables, with their default values (some auto generated) are:
118118

119119
* `traefik_constraint_tag`: The tag to be used by the internal Traefik load balancer (for example, to divide requests between backend and frontend) for production. Used to separate this stack from any other stack you might have. This should identify each stack in each environment (production, staging, etc).
120120
* `traefik_constraint_tag_staging`: The Traefik tag to be used while on staging.
121-
* `traefik_public_network`: This assumes you have another separate publicly facing Traefik at the server / cluster level. This is the network that main Traefik lives in.
122121
* `traefik_public_constraint_tag`: The tag that should be used by stack services that should communicate with the public.
123122

124123
* `flower_auth`: Basic HTTP authentication for flower, in the form`user:password`. By default: "`root:changethis`".

cookiecutter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
"traefik_constraint_tag": "{{cookiecutter.domain_main}}",
2525
"traefik_constraint_tag_staging": "{{cookiecutter.domain_staging}}",
26-
"traefik_public_network": "traefik-public",
2726
"traefik_public_constraint_tag": "traefik-public",
2827

2928
"flower_auth": "admin:{{cookiecutter.first_superuser_password}}",

{{cookiecutter.project_slug}}/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ DOMAIN=localhost
66
# DOMAIN=localhost.tiangolo.com
77
# DOMAIN=dev.{{cookiecutter.domain_main}}
88

9+
TRAEFIK_PUBLIC_NETWORK=traefik-public
910
TRAEFIK_TAG={{cookiecutter.traefik_constraint_tag}}
10-
TRAEFIK_PUBLIC_NETWORK={{cookiecutter.traefik_public_network}}
1111
TRAEFIK_PUBLIC_TAG={{cookiecutter.traefik_public_constraint_tag}}
1212

1313
DOCKER_IMAGE_BACKEND={{cookiecutter.docker_image_backend}}

{{cookiecutter.project_slug}}/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,24 @@ And you can use CI (continuous integration) systems to do it automatically.
394394

395395
But you have to configure a couple things first.
396396

397+
### Traefik network
398+
399+
This stack expects the public Traefik network to be named `traefik-public`, just as in the tutorial in <a href="https://dockerswarm.rocks" class="external-link" target="_blank">DockerSwarm.rocks</a>.
400+
401+
If you need to use a different Traefik public network name, update it in the `docker-compose.yml` files, in the section:
402+
403+
```YAML
404+
networks:
405+
traefik-public:
406+
external: true
407+
```
408+
409+
Change `traefik-public` to the name of the used Traefik network. And then update it in the file `.env`:
410+
411+
```bash
412+
TRAEFIK_PUBLIC_NETWORK=traefik-public
413+
```
414+
397415
### Persisting Docker named volumes
398416

399417
You need to make sure that each service (Docker container) that uses a volume is always deployed to the same Docker "node" in the cluster, that way it will preserve the data. Otherwise, it could be deployed to a different node each time, and each time the volume would be created in that new node before starting the service. As a result, it would look like your service was starting from scratch every time, losing all the previous data.
@@ -402,7 +420,6 @@ That's specially important for a service running a database. But the same proble
402420

403421
To solve that, you can put constraints in the services that use one or more data volumes (like databases) to make them be deployed to a Docker node with a specific label. And of course, you need to have that label assigned to one (only one) of your nodes.
404422

405-
406423
#### Adding services with volumes
407424

408425
For each service that uses a volume (databases, services with uploaded files, etc) you should have a label constraint in your `docker-compose.deploy.volumes-placement.yml` file.

{{cookiecutter.project_slug}}/cookiecutter-config-file.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ default_context:
1919
pgadmin_default_user_password: '{{ cookiecutter.pgadmin_default_user_password }}'
2020
traefik_constraint_tag: '{{ cookiecutter.traefik_constraint_tag }}'
2121
traefik_constraint_tag_staging: '{{ cookiecutter.traefik_constraint_tag_staging }}'
22-
traefik_public_network: '{{ cookiecutter.traefik_public_network }}'
2322
traefik_public_constraint_tag: '{{ cookiecutter.traefik_public_constraint_tag }}'
2423
flower_auth: '{{ cookiecutter.flower_auth }}'
2524
sentry_dsn: '{{ cookiecutter.sentry_dsn }}'

{{cookiecutter.project_slug}}/docker-compose.deploy.networks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ services:
1414
- default
1515

1616
networks:
17-
{{cookiecutter.traefik_public_network}}:
17+
traefik-public:
1818
external: true

0 commit comments

Comments
 (0)