From 0cb3812ac03c4992e3092fec0c2c373cbc83447c Mon Sep 17 00:00:00 2001
From: Norm <normandy@biribiri.dev>
Date: Mon, 7 Aug 2023 13:08:54 -0400
Subject: [PATCH] Add docker override file to docs and gitignore

The docker-compose.yml file is likely to be edited quite extensively by
admins when setting up an instance. This would likely cause problems
when dealing with updating Akkoma as merge conflicts would likely occur.

Docker-compose already has the ability to use override files in addition
to the main `docker-compose.yml` file. Admins can instead put any
overrides (additional volumes, container for elasticsearch, etc.) into a
file that won't be tracked by git and thus won't run into merge
conflicts in the future. In particular, the
`docker-compose.override.yml` will be checked by docker compose in
addition to the main file if it exists and override definitions from the
latter with the former.
---
 .gitignore                          |  1 +
 docker-compose.yml                  |  2 +-
 docs/docs/installation/docker_en.md | 27 ++++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8821d8ce1..b7411cb3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ docs/venv
 # docker stuff
 docker-db
 *.iml
+docker-compose.override.yml
diff --git a/docker-compose.yml b/docker-compose.yml
index 0dedbc87e..bfa2aff73 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -45,7 +45,7 @@ services:
     volumes:
       - .:/opt/akkoma
 
-  # Uncomment the following if you want to use a reverse proxy
+  # Copy this into docker-compose.override.yml and uncomment there if you want to use a reverse proxy
   #proxy:
   #  image: caddy:2-alpine
   #  restart: unless-stopped
diff --git a/docs/docs/installation/docker_en.md b/docs/docs/installation/docker_en.md
index 52c056173..9551b034a 100644
--- a/docs/docs/installation/docker_en.md
+++ b/docs/docs/installation/docker_en.md
@@ -125,7 +125,26 @@ cp docker-resources/Caddyfile.example docker-resources/Caddyfile
 
 Then edit the TLD in your caddyfile to the domain you're serving on.
 
-Uncomment the `caddy` section in the docker compose file,
+Copy the commented out `caddy` section in `docker-compose.yml` into a new file called `docker-compose.override.yml` like so:
+```yaml
+version: "3.7"
+
+services:
+  proxy:
+    image: caddy:2-alpine
+    restart: unless-stopped
+    links:
+      - akkoma
+    ports: [
+       "443:443",
+       "80:80"
+    ]
+    volumes:
+      - ./docker-resources/Caddyfile:/etc/caddy/Caddyfile
+      - ./caddy-data:/data
+      - ./caddy-config:/config
+```
+
 then run `docker compose up -d` again.
 
 #### Running a reverse proxy on the host
@@ -155,6 +174,12 @@ git pull
 docker compose restart akkoma db
 ```
 
+### Modifying the Docker services
+If you want to modify the services defined in the docker compose file, you can
+create a new file called `docker-compose.override.yml`. There you can add any
+overrides or additional services without worrying about git conflicts when a
+new release comes out.
+
 #### Further reading
 
 {! installation/further_reading.include !}