Skip to content

Commit

Permalink
fixed bug where the node container counldn't connect properly to the …
Browse files Browse the repository at this point in the history
…redis container in docker compose
  • Loading branch information
jakewmeyer committed Aug 26, 2018
1 parent 6eda2ab commit 3e70fd1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ WORKDIR /app
COPY --from=0 /app .
COPY . .
ENV NODE_ENV=production
ENV DOCKER=true
EXPOSE 5000
CMD ["node", "src/app.js"]
11 changes: 9 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
version: '3'

networks:
redis:
driver: bridge

services:
node:
build: .
volumes:
- ".:/src/app"
ports:
- "5000:5000"
links:
- redis_db
networks:
- redis
redis_db:
image: redis:alpine
ports:
- "6379"
networks:
- redis
3 changes: 3 additions & 0 deletions src/middleware/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const options = {
expire: 86400,
}],
passParam: 'pretty',
redis: {
host: process.env.DOCKER ? 'redis_db' : 'localhost',
},
};

module.exports = options;

0 comments on commit 3e70fd1

Please sign in to comment.