Explorar o código

Updated docker-compose to persist mongo db and not expose ports publicly

Owen Diffey %!s(int64=3) %!d(string=hai) anos
pai
achega
52c799cb21
Modificáronse 2 ficheiros con 6 adicións e 7 borrados
  1. 2 1
      .env.example
  2. 4 6
      docker-compose.yml

+ 2 - 1
.env.example

@@ -2,6 +2,7 @@ REDIS_PASSWORD=PASSWORD
 
 BACKEND_PORT=8080
 FRONTEND_PORT=80
+HOST=127.0.0.1
 
 MONGO_PORT=27017
 MONGO_ROOT_PASSWORD=PASSWORD_HERE
@@ -14,4 +15,4 @@ REDIS_PORT=6379
 
 COMPOSE_PROJECT_NAME=musare
 
-FRONTEND_MODE=dev
+FRONTEND_MODE=dev

+ 4 - 6
docker-compose.yml

@@ -4,7 +4,7 @@ services:
   backend:
     build: ./backend
     ports:
-      - "${BACKEND_PORT}:8080"
+      - "${HOST}:${BACKEND_PORT}:8080"
     volumes:
       - ./backend:/opt/app
       - ./log:/opt/log
@@ -17,7 +17,7 @@ services:
   frontend:
     build: ./frontend
     ports:
-      - "${FRONTEND_PORT}:80"
+      - "${HOST}:${FRONTEND_PORT}:80"
     volumes:
       - ./frontend:/opt/app
       - /opt/app/node_modules/
@@ -26,8 +26,6 @@ services:
 
   mongo:
     image: mongo:4.0
-    ports:
-      - "${MONGO_PORT}:27017"
     environment:
       - MONGO_INITDB_ROOT_USERNAME=admin
       - MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
@@ -38,11 +36,11 @@ services:
       - MONGO_USER_PASSWORD=${MONGO_USER_PASSWORD}
     volumes:
       - ./tools/docker/setup-mongo.sh:/docker-entrypoint-initdb.d/setup-mongo.sh
+      - ./.db:/data/db
 
   redis:
     image: redis
     command: "--notify-keyspace-events Ex --requirepass ${REDIS_PASSWORD} --appendonly yes"
     volumes:
       - .redis:/data
-    ports:
-      - "${REDIS_PORT}:6379"
+