Browse Source

fix need to change traefik network by name

Victor Noël 7 years ago
parent
commit
85ce610b23
3 changed files with 17 additions and 14 deletions
  1. 2 3
      README.md
  2. 4 8
      docker-compose.yml
  3. 11 3
      setup.sh

+ 2 - 3
README.md

@@ -50,9 +50,8 @@ cd docker-atelier
 # Configure environment variables in setup.sh then run it
 ./setup.sh
 
-# Deploy Services
-# Note: docker-compose's traefik.docker.network contains references to the project's name (see https://github.com/containous/traefik/issues/2348)
-docker-compose -d -p oxyta up
+# Deploy Services (project name should only be set via the setup.sh file!)
+docker-compose -d up
 ```
 
 ## Configure mail

+ 4 - 8
docker-compose.yml

@@ -25,8 +25,7 @@ services:
       - traefik
     labels:
       - "traefik.backend=nextcloud"
-      # See README and https://github.com/containous/traefik/issues/2348 for network name
-      - "traefik.docker.network=oxyta_traefik"
+      - "traefik.docker.network=${COMPOSE_PROJECT_NAME}_traefik"
       - "traefik.frontend.rule=Host:cloud.${CHATONS_DOMAIN}"
       - "traefik.enable=true"
       - "traefik.port=80"
@@ -49,8 +48,7 @@ services:
     hostname: 'git.${CHATONS_DOMAIN}' # required by gitlab
     labels:
       - "traefik.backend=gitlab"
-      # See README and https://github.com/containous/traefik/issues/2348 for network name
-      - "traefik.docker.network=oxyta_traefik"
+      - "traefik.docker.network=${COMPOSE_PROJECT_NAME}_traefik"
       - "traefik.frontend.rule=Host:git.${CHATONS_DOMAIN}"
       - "traefik.enable=true"
       - "traefik.port=80"
@@ -73,8 +71,7 @@ services:
       - traefik
     labels:
       - "traefik.backend=homepage"
-      # See README and https://github.com/containous/traefik/issues/2348 for network name
-      - "traefik.docker.network=oxyta_traefik"
+      - "traefik.docker.network=${COMPOSE_PROJECT_NAME}_traefik"
       # note: www must also be present because we need its certificate
       # and it is required for traefik redirection to work too (in traefik.yml)
       - "traefik.frontend.rule=Host:${CHATONS_DOMAIN},www.${CHATONS_DOMAIN}"
@@ -109,8 +106,7 @@ services:
       - ETHERPAD_TITLE=Bloc Note
     labels:
       - "traefik.backend=etherpad"
-      # See README and https://github.com/containous/traefik/issues/2348 for network name
-      - "traefik.docker.network=oxyta_traefik"
+      - "traefik.docker.network=${COMPOSE_PROJECT_NAME}_traefik"
       - "traefik.frontend.rule=Host:pad.${CHATONS_DOMAIN}"
       - "traefik.enable=true"
       - "traefik.port=9001"

+ 11 - 3
setup.sh

@@ -1,9 +1,16 @@
 #!/bin/sh
 
-# Set variables
+## You can (should) customize those variables
+# the docker-compose project name
+export CHATONS_COMPOSE_PROJECT=oxyta
+# the host directory for the containers' volumes
 export CHATONS_ROOT_DIR=/srv
+# the domain name for all services
 export CHATONS_DOMAIN=oxyta.net
+# the email to which services will send important email
 export CHATONS_MAIL=services@$CHATONS_DOMAIN
+
+## Thos does not need customization
 export CHATONS_MYSQL_PASSWORD=$(openssl rand -base64 32)
 export CHATONS_MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32)
 
@@ -14,7 +21,8 @@ fi
 
 # Export common environment variables
 
-echo "CHATONS_ROOT_DIR=$CHATONS_ROOT_DIR" > .env
+echo "COMPOSE_PROJECT_NAME=$CHATONS_COMPOSE_PROJECT" > .env
+echo "CHATONS_ROOT_DIR=$CHATONS_ROOT_DIR" >> .env
 echo "CHATONS_DOMAIN=$CHATONS_DOMAIN" >> .env
 echo "CHATONS_MAIL=$CHATONS_MAIL" >> .env
 
@@ -32,4 +40,4 @@ echo "ETHERPAD_DB_PASSWORD=$CHATONS_MYSQL_ROOT_PASSWORD" >> pad/.env
 mkdir -p "$CHATONS_ROOT_DIR/traefik"
 touch "$CHATONS_ROOT_DIR/traefik/acme.json"
 chmod 600 "$CHATONS_ROOT_DIR/traefik/acme.json"
-sed "s/###DOMAIN###/$CHATONS_DOMAIN/" traefik/traefik.toml > "$CHATONS_ROOT_DIR/traefik/traefik.toml"
+sed "s/###DOMAIN###/$CHATONS_DOMAIN/" traefik/traefik.toml > "$CHATONS_ROOT_DIR/traefik/traefik.toml"