-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sanchit Bhatnagar
committed
Sep 13, 2020
1 parent
51e7647
commit 7e8a6f7
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:alpine | ||
|
||
WORKDIR '/app' | ||
|
||
COPY package.json . | ||
RUN npm install | ||
COPY . . | ||
|
||
CMD ["npm" , "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3' | ||
|
||
services: | ||
redis-server: | ||
image: 'redis' | ||
node-app: | ||
restart: on-failure | ||
build: . | ||
ports: | ||
- "4001:8081" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const express = require('express') | ||
const redis = require('redis') | ||
|
||
const app = express() | ||
|
||
const client = redis.createClient({ | ||
host: 'redis-server', | ||
port: 6379 | ||
}) | ||
|
||
client.set('visits', 0) | ||
|
||
app.get('/', (req, res) => { | ||
client.get('visits', (err, visits) => { | ||
res.send('Number of Visits is ' + visits) | ||
client.set('visits', parseInt(visits) + 1) | ||
}) | ||
}) | ||
|
||
app.listen(8081, (params) => { | ||
console.log('Lisitng on Port 8081') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"express":"*", | ||
"redis":"2.8.0" | ||
}, | ||
"scripts": { | ||
"start": "node index.js" | ||
} | ||
} |