Browse Source

feat: Configurable docker container restart policy

Owen Diffey 2 years ago
parent
commit
e6042e83d0
3 changed files with 6 additions and 4 deletions
  1. 1 0
      .env.example
  2. 1 0
      .wiki/Configuration.md
  3. 4 4
      docker-compose.yml

+ 1 - 0
.env.example

@@ -1,4 +1,5 @@
 COMPOSE_PROJECT_NAME=musare
+RESTART_POLICY=unless-stopped
 
 BACKEND_HOST=127.0.0.1
 BACKEND_PORT=8080

+ 1 - 0
.wiki/Configuration.md

@@ -98,6 +98,7 @@ The container port refers to the external docker container port, used to access
 | Property | Description |
 | --- | --- |
 | `COMPOSE_PROJECT_NAME` | Should be a unique name for this installation, especially if you have multiple instances of Musare on the same machine. |
+| `RESTART_POLICY` | Restart policy for docker containers, values can be found [here](https://docs.docker.com/config/containers/start-containers-automatically/). |
 | `BACKEND_HOST` | Backend container host. |
 | `BACKEND_PORT` | Backend container port. |
 | `FRONTEND_HOST` | Frontend container host. |

+ 4 - 4
docker-compose.yml

@@ -3,7 +3,7 @@ services:
 
   backend:
     build: ./backend
-    restart: unless-stopped
+    restart: ${RESTART_POLICY}
     ports:
       - "${BACKEND_HOST}:${BACKEND_PORT}:8080"
     volumes:
@@ -18,7 +18,7 @@ services:
 
   frontend:
     build: ./frontend
-    restart: unless-stopped
+    restart: ${RESTART_POLICY}
     ports:
       - "${FRONTEND_HOST}:${FRONTEND_PORT}:80"
     volumes:
@@ -32,7 +32,7 @@ services:
 
   mongo:
     image: mongo:5.0
-    restart: unless-stopped
+    restart: ${RESTART_POLICY}
     ports:
       - "${MONGO_HOST}:${MONGO_PORT}:${MONGO_PORT}"
     environment:
@@ -49,7 +49,7 @@ services:
 
   redis:
     image: redis:6.2
-    restart: unless-stopped
+    restart: ${RESTART_POLICY}
     ports:
       - "${REDIS_HOST}:${REDIS_PORT}:6379"
     command: "--notify-keyspace-events Ex --requirepass ${REDIS_PASSWORD} --appendonly yes"