📌 Make the public Traefik network a fixed default (#150)

to simplify development
This commit is contained in:
Sebastián Ramírez
2020-04-19 08:50:00 +02:00
committed by GitHub
parent ff55b778ba
commit d08d9314ce
6 changed files with 20 additions and 6 deletions

View File

@@ -6,8 +6,8 @@ DOMAIN=localhost
# DOMAIN=localhost.tiangolo.com
# DOMAIN=dev.{{cookiecutter.domain_main}}
TRAEFIK_PUBLIC_NETWORK=traefik-public
TRAEFIK_TAG={{cookiecutter.traefik_constraint_tag}}
TRAEFIK_PUBLIC_NETWORK={{cookiecutter.traefik_public_network}}
TRAEFIK_PUBLIC_TAG={{cookiecutter.traefik_public_constraint_tag}}
DOCKER_IMAGE_BACKEND={{cookiecutter.docker_image_backend}}

View File

@@ -394,6 +394,24 @@ And you can use CI (continuous integration) systems to do it automatically.
But you have to configure a couple things first.
### Traefik network
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>.
If you need to use a different Traefik public network name, update it in the `docker-compose.yml` files, in the section:
```YAML
networks:
traefik-public:
external: true
```
Change `traefik-public` to the name of the used Traefik network. And then update it in the file `.env`:
```bash
TRAEFIK_PUBLIC_NETWORK=traefik-public
```
### Persisting Docker named volumes
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
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.
#### Adding services with volumes
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.

View File

@@ -19,7 +19,6 @@ default_context:
pgadmin_default_user_password: '{{ cookiecutter.pgadmin_default_user_password }}'
traefik_constraint_tag: '{{ cookiecutter.traefik_constraint_tag }}'
traefik_constraint_tag_staging: '{{ cookiecutter.traefik_constraint_tag_staging }}'
traefik_public_network: '{{ cookiecutter.traefik_public_network }}'
traefik_public_constraint_tag: '{{ cookiecutter.traefik_public_constraint_tag }}'
flower_auth: '{{ cookiecutter.flower_auth }}'
sentry_dsn: '{{ cookiecutter.sentry_dsn }}'

View File

@@ -14,5 +14,5 @@ services:
- default
networks:
{{cookiecutter.traefik_public_network}}:
traefik-public:
external: true