Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
Run app with docker compose
Browse files Browse the repository at this point in the history
This requires us to configure the Redis connection since it will no longer be
available via localhost
  • Loading branch information
code-later authored and moonglum committed Jul 15, 2018
1 parent 63dbb0c commit 2be1df4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm-debug.log
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:latest

RUN mkdir /mypp

WORKDIR /myapp

COPY package*.json /myapp/

RUN npm install

COPY . .

EXPOSE 8000

CMD ["npm", "start"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"
services:
redis:
image: "redis:5.0-rc3"
restart: always
chat:
build: .
command: npm start
volumes:
- .:/myapp
- /myapp/node_modules
ports:
- "8000:8000"
depends_on:
- redis
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app.set('view engine', 'mustache')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static(path.resolve('public')))

let producer = new Redis()
let producer = new Redis('redis://redis:6379')

// 10 is an arbitrary number
app.get('/', async function (req, res) {
Expand Down Expand Up @@ -47,7 +47,7 @@ app.post('/messages', function (req, res) {

// This parameter is written into the template by Node
app.get('/update-stream', async function (req, res) {
let consumer = new Redis()
let consumer = new Redis('redis://redis:6379')

res.writeHead(200, {
'Content-Type': 'text/event-stream',
Expand Down
2 changes: 1 addition & 1 deletion redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ foo()
Redis.Command.setReplyTransformer('xread', xreadResultParser)

async function foo () {
let subscriber = new Redis()
let subscriber = new Redis('redis://redis:6379')

let lastId = '$'
while (true) {
Expand Down

0 comments on commit 2be1df4

Please sign in to comment.