-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example: example app using mongodb as a storage backend
- Loading branch information
1 parent
b35b9f6
commit 19d367b
Showing
11 changed files
with
245 additions
and
4 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
node_modules/ | ||
compose/ | ||
assets/ | ||
examples/ | ||
docs/ | ||
coverage/ | ||
tutorials/ | ||
|
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,32 @@ | ||
# -- BASE | ||
FROM buildpack-deps:stretch-curl AS base | ||
ENV storage__path /var/data/skyring | ||
ENV NODE_ENV=production | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential curl g++ make tar python | ||
|
||
ENV NODE_VERSION 8.7.0 | ||
|
||
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" | ||
RUN tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 | ||
|
||
# -- BUILD | ||
FROM base AS build | ||
|
||
COPY package*.json /opt/skyring/ | ||
WORKDIR /opt/skyring | ||
RUN npm install && mv node_modules prod_node_modules | ||
|
||
# -- RELEASE | ||
FROM debian:stretch-slim as skyring | ||
RUN mkdir -p /var/data/skyring | ||
WORKDIR /opt/skyring | ||
VOLUME /etc | ||
VOLUME /var/data/skyring | ||
|
||
COPY --from=build /usr/local/bin/node /usr/local/bin/node | ||
COPY --from=build /usr/local/bin/npm /usr/local/bin/npm | ||
COPY --from=build /usr/local/include/node /usr/local/include | ||
COPY --from=build /opt/skyring/prod_node_modules ./node_modules | ||
COPY . . | ||
CMD ["node", "index.js"] |
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,3 @@ | ||
## MONGO-STORAGE | ||
|
||
Skying cluster using a mongodb instance for external storage |
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,112 @@ | ||
version: '2' | ||
services: | ||
node-1: | ||
build: ./ | ||
hostname: node-1 | ||
environment: | ||
DEBUG: '*' | ||
channel__host: 'node-1' | ||
nats__hosts: 'nats-a:4222,nats-b:4222,nats-c:4222' | ||
seeds: 'node-1:3455,node-2:3456' | ||
storage__backend: 'mongodown' | ||
storage__path: 'mongodb://mongo:27017/skyring' | ||
storage__collection: 'skyring-1' | ||
networks: | ||
- mongoring | ||
depends_on: | ||
- nats-a | ||
- nats-b | ||
- nats-c | ||
- mongo | ||
|
||
node-2: | ||
build: ./ | ||
hostname: node-2 | ||
environment: | ||
DEBUG: '*' | ||
seeds: 'node-1:3455,node-2:3456' | ||
nats__hosts: 'nats-a:4222,nats-b:4222,nats-c:4222' | ||
channel__host: 'node-2' | ||
channel__port: 3456 | ||
storage__backend: 'mongodown' | ||
storage__path: 'mongodb://mongo:27017/skyring' | ||
storage__collection: 'skyring-2' | ||
networks: | ||
- mongoring | ||
depends_on: | ||
- nats-a | ||
- nats-b | ||
- nats-c | ||
- mongo | ||
|
||
node-3: | ||
build: ./ | ||
hostname: node-3 | ||
environment: | ||
DEBUG: '*' | ||
seeds: 'node-1:3455,node-2:3456' | ||
nats__hosts: 'nats-a:4222,nats-b:4222,nats-c:4222' | ||
channel__host: 'node-3' | ||
storage__backend: 'mongodown' | ||
storage__path: 'mongodb://mongo:27017/skyring' | ||
storage__collection: 'skyring-3' | ||
networks: | ||
- mongoring | ||
depends_on: | ||
- nats-a | ||
- nats-b | ||
- nats-c | ||
- node-1 | ||
- node-2 | ||
- mongo | ||
|
||
nats-a: | ||
image: nats:latest | ||
volumes: | ||
- ./etc/nats:/tmp | ||
command: > | ||
-c /tmp/a.conf -D | ||
networks: | ||
- mongoring | ||
nats-b: | ||
image: nats:latest | ||
volumes: | ||
- ./etc/nats:/tmp | ||
command: > | ||
-c /tmp/b.conf -D | ||
depends_on: | ||
- nats-a | ||
networks: | ||
- mongoring | ||
nats-c: | ||
image: nats:latest | ||
volumes: | ||
- ./etc/nats:/tmp | ||
depends_on: | ||
- nats-a | ||
command: > | ||
-c /tmp/c.conf -D | ||
networks: | ||
- mongoring | ||
|
||
mongo: | ||
image: mongo:3.6 | ||
networks: | ||
- mongoring | ||
|
||
nginx: | ||
image: 'nginx:latest' | ||
volumes: | ||
- ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf | ||
ports: | ||
- "8080:80" | ||
networks: | ||
- mongoring | ||
depends_on: | ||
- node-1 | ||
- node-2 | ||
- node-3 | ||
|
||
networks: | ||
mongoring: | ||
driver: bridge |
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 @@ | ||
port: 4222 | ||
cluster { | ||
host: '0.0.0.0' | ||
port: 6222 | ||
routes = [ | ||
nats-route://nats-b:6222 | ||
nats-route://nats-c:6222 | ||
] | ||
} |
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 @@ | ||
port: 4222 | ||
cluster { | ||
host: '0.0.0.0' | ||
port: 6222 | ||
routes = [ | ||
nats-route://nats-a:6222 | ||
nats-route://nats-c:6222 | ||
] | ||
} |
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 @@ | ||
port: 4222 | ||
cluster { | ||
host: '0.0.0.0' | ||
port: 6222 | ||
routes = [ | ||
nats-route://nats-a:6222 | ||
nats-route://nats-b:6222 | ||
] | ||
} | ||
|
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,54 @@ | ||
#user nobody; | ||
worker_processes 8; | ||
|
||
#error_log logs/error.log; | ||
#error_log logs/error.log notice; | ||
#error_log logs/error.log info; | ||
|
||
#pid logs/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 2048; | ||
} | ||
|
||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
#access_log logs/access.log main; | ||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
#keepalive_timeout 0; | ||
#gzip on; | ||
keepalive_timeout 65; | ||
proxy_read_timeout 200; | ||
gzip_http_version 1.0; | ||
gzip_min_length 0; | ||
gzip_types text/plain text/css text/javascript application/javascript application/json applicatin/x-javascript application/x-json; | ||
gzip_buffers 16 8k; | ||
gzip_comp_level 9; | ||
gzip_vary on; | ||
proxy_next_upstream error; | ||
|
||
upstream skyring { | ||
server node-1:3000; | ||
server node-2:3000; | ||
server node-3:3000; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name skyring; | ||
|
||
location / { | ||
proxy_pass_header Server; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Scheme $scheme; | ||
proxy_pass http://skyring; | ||
} | ||
} | ||
} |
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,11 @@ | ||
'use strict' | ||
|
||
const http = require('http') | ||
let count = 0 | ||
const server = http.createServer((req, res) => { | ||
res.writeHead(204) | ||
res.end('') | ||
console.log(++count) | ||
}) | ||
|
||
server.listen(process.env.PORT || 4000) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -17,6 +17,6 @@ | |
"license": "MIT", | ||
"dependencies": { | ||
"mongodown": "^1.2.0", | ||
"skyring": "^5.1.0" | ||
"skyring": "^6.0.0-alpha.1" | ||
} | ||
} |