From 7288010e555d7f7ccc20c4330634976e18d6fa77 Mon Sep 17 00:00:00 2001
From: Daniel Wiesenberg <weasy@hotmail.de>
Date: Tue, 4 Aug 2020 22:04:27 +0200
Subject: [PATCH] Move additional files into dedicated folder and make build
 the def...

...fault in the compose files.
---
 Dockerfile                                    |  4 ++--
 docker-compose.override.traefik.yml           | 21 -----------------
 docker-compose.yml                            | 23 ++++++++++---------
 docker/docker-compose.override.traefik.yml    | 22 ++++++++++++++++++
 .../docker-compose.traefik.yml                | 23 ++++++++++---------
 5 files changed, 48 insertions(+), 45 deletions(-)
 delete mode 100644 docker-compose.override.traefik.yml
 create mode 100644 docker/docker-compose.override.traefik.yml
 rename docker-compose.traefik.yml => docker/docker-compose.traefik.yml (77%)

diff --git a/Dockerfile b/Dockerfile
index e185381a..7aa05c0f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,7 @@
 
 
 ##########################  BUILD IMAGE  ##########################
-# Alpine build image to build Conduits statically compiled binary
+# Alpine build image to build Conduit's statically compiled binary
 FROM alpine:3.12 as builder
 
 # Specifies if the local project is build or if Conduit gets build
@@ -51,7 +51,7 @@ LABEL org.opencontainers.image.created=${CREATED} \
       org.opencontainers.image.vendor="Conduit Contributors" \
       org.opencontainers.image.description="A Matrix homeserver written in Rust" \
       org.opencontainers.image.url="https://conduit.rs/" \
-      org.opencontainers.image.revision=$GIT_REF \
+      org.opencontainers.image.revision=${GIT_REF} \
       org.opencontainers.image.source="https://git.koesters.xyz/timo/conduit.git" \
       org.opencontainers.image.documentation.="" \
       org.opencontainers.image.licenses="AGPL-3.0" \
diff --git a/docker-compose.override.traefik.yml b/docker-compose.override.traefik.yml
deleted file mode 100644
index 8b4be50b..00000000
--- a/docker-compose.override.traefik.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-# Conduit - Traefik Reverse Proxy Labels
-version: '3'
-
-services:
-    homeserver:
-        labels:
-            - "traefik.enable=true"
-            - "traefik.docker.network=proxy"  # Change this to the name of your Traefik docker proxy network
-
-            - "traefik.http.routers.to-conduit.rule=Host(`<SUBDOMAIN>.<DOMAIN>`)"  # Change to the address on which Conduit is hosted
-            - "traefik.http.routers.to-conduit.tls=true"
-            - "traefik.http.routers.to-conduit.tls.certresolver=letsencrypt"
-
-    element-web:
-        labels:
-            - "traefik.enable=true"
-            - "traefik.docker.network=proxy"  # Change this to the name of your Traefik docker proxy network
-
-            - "traefik.http.routers.to-element-web.rule=Host(`<SUBDOMAIN>.<DOMAIN>`)"  # Change to the address on which Element-Web is hosted
-            - "traefik.http.routers.to-element-web.tls=true"
-            - "traefik.http.routers.to-element-web.tls.certresolver=letsencrypt"
diff --git a/docker-compose.yml b/docker-compose.yml
index 48470e6e..afd36990 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,17 +3,18 @@ version: '3'
 
 services:
     homeserver:
-        ### If you already built the Conduit image with 'docker build', then you are ready to
-        ### go. Otherwise, you need to comment the 'image' line and uncomment the 'build' lines
-        ### and run: CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up -d
-        image: conduit_homeserver:latest
-        # build:
-        #     context: .
-        #     args:
-        #         CREATED:
-        #         VERSION:
-        #         LOCAL: "false"
-        #         GIT_REF: HEAD
+        ### If you already built the Conduit image with 'docker build', then you can uncomment the
+        ### 'image' line and comment out the 'build' option.
+        # image: conduit_homeserver:latest
+        ### If you want meaningful labels in you built Conduit image, you should run docker-compose like this:
+        ### CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up -d
+        build:
+            context: .
+            args:
+                CREATED:
+                VERSION:
+                LOCAL: "false"
+                GIT_REF: HEAD
         restart: unless-stopped
         ports:
             - 8448:8000
diff --git a/docker/docker-compose.override.traefik.yml b/docker/docker-compose.override.traefik.yml
new file mode 100644
index 00000000..2096d792
--- /dev/null
+++ b/docker/docker-compose.override.traefik.yml
@@ -0,0 +1,22 @@
+# Conduit - Traefik Reverse Proxy Labels
+version: '3'
+
+services:
+    homeserver:
+        labels:
+            - "traefik.enable=true"
+            - "traefik.docker.network=proxy"  # Change this to the name of your Traefik docker proxy network
+
+            - "traefik.http.routers.to-conduit.rule=Host(`<SUBDOMAIN>.<DOMAIN>`)"  # Change to the address on which Conduit is hosted
+            - "traefik.http.routers.to-conduit.tls=true"
+            - "traefik.http.routers.to-conduit.tls.certresolver=letsencrypt"
+
+    ### Uncomment this if you uncommented Element-Web App in the docker-compose.yml
+    # element-web:
+    #     labels:
+    #         - "traefik.enable=true"
+    #         - "traefik.docker.network=proxy"  # Change this to the name of your Traefik docker proxy network
+
+    #         - "traefik.http.routers.to-element-web.rule=Host(`<SUBDOMAIN>.<DOMAIN>`)"  # Change to the address on which Element-Web is hosted
+    #         - "traefik.http.routers.to-element-web.tls=true"
+    #         - "traefik.http.routers.to-element-web.tls.certresolver=letsencrypt"
diff --git a/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml
similarity index 77%
rename from docker-compose.traefik.yml
rename to docker/docker-compose.traefik.yml
index 8edc29ca..ad1dad82 100644
--- a/docker-compose.traefik.yml
+++ b/docker/docker-compose.traefik.yml
@@ -3,17 +3,18 @@ version: '3'
 
 services:
     homeserver:
-        ### If you already built the Conduit image with 'docker build', then you are ready to
-        ### go. Otherwise, you need to comment the 'image' line and uncomment the 'build' lines
-        ### and run: CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up -d
-        image: conduit_homeserver:latest
-        # build:
-        #     context: .
-        #     args:
-        #         CREATED:
-        #         VERSION:
-        #         LOCAL: false
-        #         GIT_REF: HEAD
+        ### If you already built the Conduit image with 'docker build', then you can uncomment the
+        ### 'image' line and comment out the 'build' option.
+        # image: conduit_homeserver:latest
+        ### If you want meaningful labels in you built Conduit image, you should run docker-compose like this:
+        ### CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up -d
+        build:
+            context: .
+            args:
+                CREATED:
+                VERSION:
+                LOCAL: false
+                GIT_REF: HEAD
         restart: unless-stopped
         volumes:
             - db:/srv/conduit/.local/share/conduit