This file contains hidden or 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
$ curl -i -X POST --url http://localhost:8001/services/ --data 'name=kc-chat-backend' \ | |
--data 'url=http://172.19.0.4' --data 'port=10000' | |
# Sample output | |
HTTP/1.1 201 Created | |
Content-Type: application/json; charset=utf-8 | |
Connection: keep-alive | |
Access-Control-Allow-Origin: * | |
Server: kong/1.4.3 | |
Content-Length: 295 |
This file contains hidden or 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
$ docker network inspect kong-net | |
# Sample output | |
[ | |
{ | |
"Name": "kong-net", | |
"Id": "1176776a97a0d22a44789cdd8fb4408cb80e4af086ac6474ab503704fda06c40", | |
# ... | |
"Containers": { | |
# ... "3a21018c6c9a6c0877ac182e7cd0e3e3da0af87b36d1f2a4882f76fe43a03a27": { | |
"Name": "kc_backend", |
This file contains hidden or 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
version: '3' | |
services: | |
kc_backend: | |
build: ./backend | |
image: kc_backend | |
container_name: kc_backend | |
network_mode: kong-net |
This file contains hidden or 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
FROM node:carbon-alpine | |
WORKDIR /app | |
COPY package.json ./ | |
RUN npm install | |
COPY . . | |
EXPOSE 10000 | |
CMD ["npm", "start"] |
This file contains hidden or 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
{ | |
"scripts": { | |
"start": "node index.js" | |
}, | |
} |
This file contains hidden or 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
KC_STREAM_CHAT_KEY=xxxx | |
KC_STREAM_CHAT_SECRET=xxxx |
This file contains hidden or 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
require('dotenv').config(); | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const ip = require('ip'); | |
const { StreamChat } = require('stream-chat'); | |
const app = express(); | |
// Add the middlewares | |
app.use(bodyParser.json()); |
This file contains hidden or 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
$ mkdir -p kongchat/{frontend,backend} | |
$ cd kongchat/backend | |
$ touch index.js | |
$ npm init -y | |
$ npm i express body-parser dotenv stream-chat ip |
This file contains hidden or 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
$ docker network create kong-net | |
$ docker run -d --name kong-database --network=kong-net \ | |
-p 5432:5432 -e "POSTGRES_USER=kong" \ | |
-e "POSTGRES_DB=kong" postgres:9.6 | |
$ docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" \ | |
-e "KONG_PG_HOST=kong-database" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ | |
kong:latest kong migrations bootstrap |
This file contains hidden or 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
docker network create kong-net | |
docker run -d --name kong-database --network=kong-net \ | |
-p 5432:5432 -e "POSTGRES_USER=kong" \ | |
-e "POSTGRES_DB=kong" postgres:9.6 | |
docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" \ | |
-e "KONG_PG_HOST=kong-database" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ | |
kong:latest kong migrations bootstrap |