Skip to content

Commit fe7c740

Browse files
committed
add redis docker compose
1 parent 16305a3 commit fe7c740

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ DB_USER_PWD=changeit
3535
DB_ADMIN=admin
3636
DB_ADMIN_PWD=changeit
3737

38+
# Redis
39+
REDIS_CACHE_PORT=
40+
REDIS_CACHE_PASSWORD=
41+
3842
# Log
3943
# Example '/home/node/logs'
4044
# DEFAUlT is this project's directory

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
- '$PORT:$PORT'
2121
links:
2222
- mongo
23+
- redis
2324

2425
mongo:
2526
# To create this service, Compose will pull the mongo
@@ -45,9 +46,22 @@ services:
4546
# This will ensure that you don’t lose data in cases where you stop or remove containers.
4647
- dbdata:/data/db
4748

49+
redis:
50+
image: redis:7.0.5
51+
container_name: redis
52+
restart: unless-stopped
53+
env_file: .env
54+
ports:
55+
- '$REDIS_CACHE_PORT:6379'
56+
command: redis-server --save 20 1 --loglevel warning --requirepass $REDIS_CACHE_PASSWORD
57+
volumes:
58+
- cache:/data/cache
59+
4860
# Our top-level volumes key defines the volumes dbdata.
4961
# When Docker creates volumes, the contents of the volume are stored in a part of the host filesystem, /var/lib/docker/volumes/, that’s managed by Docker.
5062
# The contents of each volume are stored in a directory under /var/lib/docker/volumes/ and get mounted to any container that uses the volume.
5163
# In this way, the data that our users will create will persist in the dbdata volume even if we remove and recreate the db container.
5264
volumes:
5365
dbdata:
66+
cache:
67+
driver: local

tests/.env.test.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ DB_USER=blogs-test-db-user
3030
# YOUR_TEST_MONGO_DB_USER_PWD
3131
DB_USER_PWD=changeit
3232

33+
# Redis
34+
REDIS_CACHE_PORT=6379
35+
REDIS_CACHE_PASSWORD=changeit
36+
3337
# Log
3438
# Example '/home/node/logs'
3539
# DEFAUlT is this project's directory

0 commit comments

Comments
 (0)