Skip to content

Instantly share code, notes, and snippets.

View ukchukx's full-sized avatar
💭
Unus sed leo

Uk ukchukx

💭
Unus sed leo
View GitHub Profile
$ 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
$ docker network inspect kong-net
# Sample output
[
{
"Name": "kong-net",
"Id": "1176776a97a0d22a44789cdd8fb4408cb80e4af086ac6474ab503704fda06c40",
# ...
"Containers": {
# ... "3a21018c6c9a6c0877ac182e7cd0e3e3da0af87b36d1f2a4882f76fe43a03a27": {
"Name": "kc_backend",
version: '3'
services:
kc_backend:
build: ./backend
image: kc_backend
container_name: kc_backend
network_mode: kong-net
FROM node:carbon-alpine
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 10000
CMD ["npm", "start"]
{
"scripts": {
"start": "node index.js"
},
}
KC_STREAM_CHAT_KEY=xxxx
KC_STREAM_CHAT_SECRET=xxxx
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());
$ mkdir -p kongchat/{frontend,backend}
$ cd kongchat/backend
$ touch index.js
$ npm init -y
$ npm i express body-parser dotenv stream-chat ip
$ 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
@ukchukx
ukchukx / stream_chat_kong_1.sh
Created January 21, 2020 19:17
Steps to running Kong using Docker
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