From 9f2b5ea86e789069becbefe1d9672f2cac6e8708 Mon Sep 17 00:00:00 2001
From: Stormrover <86500521+twomoses@users.noreply.github.com>
Date: Tue, 30 May 2023 21:53:24 -0400
Subject: [PATCH] Allow docker image version pinning (#2617)

* Allow docker image version pinning

* Updating docker-compose documentation.

* Fixing formatting

* Added Optional to documentation.
---
 docker/docker-compose.yml           | 10 +++++-----
 docker/example.env                  |  9 +++++++++
 docs/docs/install/docker-compose.md | 11 +++++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 1915548aa4..17f766e82c 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -3,7 +3,7 @@ version: "3.8"
 services:
   immich-server:
     container_name: immich_server
-    image: ghcr.io/immich-app/immich-server:release
+    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
     command: ["start-server.sh"]
     volumes:
       - ${UPLOAD_LOCATION}:/usr/src/app/upload
@@ -17,7 +17,7 @@ services:
 
   immich-microservices:
     container_name: immich_microservices
-    image: ghcr.io/immich-app/immich-server:release
+    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
     command: ["start-microservices.sh"]
     volumes:
       - ${UPLOAD_LOCATION}:/usr/src/app/upload
@@ -31,7 +31,7 @@ services:
 
   immich-machine-learning:
     container_name: immich_machine_learning
-    image: ghcr.io/immich-app/immich-machine-learning:release
+    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
     volumes:
       - ${UPLOAD_LOCATION}:/usr/src/app/upload
       - model-cache:/cache
@@ -41,7 +41,7 @@ services:
 
   immich-web:
     container_name: immich_web
-    image: ghcr.io/immich-app/immich-web:release
+    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
     env_file:
       - .env
     restart: always
@@ -79,7 +79,7 @@ services:
 
   immich-proxy:
     container_name: immich_proxy
-    image: ghcr.io/immich-app/immich-proxy:release
+    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
     environment:
       # Make sure these values get passed through from the env file
       - IMMICH_SERVER_URL
diff --git a/docker/example.env b/docker/example.env
index f46459e45b..eef325b1f8 100644
--- a/docker/example.env
+++ b/docker/example.env
@@ -105,3 +105,12 @@ IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003
 ####################################################################################
 
 #IMMICH_API_URL_EXTERNAL=http://localhost:3001
+
+###################################################################################
+# Immich Version - Optional
+#
+# This allows all immich docker images to be pinned to a specific version. By default, 
+# the version is "release" but could be a specific version, like "v1.59.0".
+###################################################################################
+
+#IMMICH_VERSION=
diff --git a/docs/docs/install/docker-compose.md b/docs/docs/install/docker-compose.md
index 4c4e466b85..4dbae958aa 100644
--- a/docs/docs/install/docker-compose.md
+++ b/docs/docs/install/docker-compose.md
@@ -136,6 +136,15 @@ IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003
 ####################################################################################
 
 #IMMICH_API_URL_EXTERNAL=http://localhost:3001
+
+###################################################################################
+# Immich Version - Optional
+#
+# This allows all immich docker images to be pinned to a specific version. By default,
+# the version is "release" but could be a specific version, like "v1.59.0".
+###################################################################################
+
+#IMMICH_VERSION=
 ```
 
 </details>
@@ -159,6 +168,8 @@ For more information on how to use the application, please refer to the [Post In
 
 ### Step 4 - Upgrading
 
+If `IMMICH_VERSION` is set, it will need to be updated to the latest or desired version.
+
 When a new version of Immich is [released](https://github.com/immich-app/immich/releases), the application can be upgraded with the following commands, run in the directory with the `docker-compose.yml` file:
 
 ```bash title="Upgrade Immich"