Browse Source

Rolled out in prod

master
Lauri Võsandi 7 months ago
parent
commit
bca9264ce9
  1. 3
      .env
  2. 1
      .gitignore
  3. BIN
      .overnodebundle
  4. 9
      README.md
  5. 12
      docker-compose.yml
  6. 9
      main.py
  7. 6
      overnode.yml

3
.env

@ -1,3 +0,0 @@
# MONGO_URI=mongodb://root:salakala@localhost:27017/?replicaSet=kspace-mongo-set
MONGO_URI=mongodb://root:salakala@localhost:27017
DOORBOY_SECRET=doorboy_secret

1
.gitignore

@ -0,0 +1 @@
.env

BIN
.overnodebundle

Binary file not shown.

9
README.md

@ -0,0 +1,9 @@
# Deploying
```
docker build -t 172.20.40.1:5000/doorboy:latest .
docker push 172.20.40.1:5000/doorboy:latest
overnode pull
overnode up
```

12
docker-compose.yml

@ -5,14 +5,12 @@ networks:
external: true
services:
doorboy_proxy:
hostname: doorboy.infra.k-space.ee
app:
image: 172.20.40.1:5000/doorboy:latest
hostname: replica${OVERNODE_ID}.doorboy.infra.k-space.ee
restart: unless-stopped
env_file: .env
networks:
infra:
ipv4_address: 172.21.99.97
build:
context: .
ipv4_address: 172.21.57.${OVERNODE_ID}
ipv6_address: 2001:bb8:4008:21:57::${OVERNODE_ID}

9
main.py

@ -9,9 +9,8 @@ import const
app = Sanic(__name__)
#mongodb = MongoClient('mongodb://172.21.27.1,172.21.27.2,172.21.27.3:27017/', replicaSet="kspace-mongo-set").kspace_accounting
mongodb = AsyncIOMotorClient(const.MONGO_URI)
mongodb = mongodb.get_default_database()
db = mongodb.get_default_database()
DOORBOY_SECRET = os.environ["DOORBOY_SECRET"]
@ -22,10 +21,10 @@ async def view_doorboy_uids(request):
if request.headers.get('KEY') != DOORBOY_SECRET:
return text("how about no")
allowed_names = []
async for obj in mongodb.member.find({"enabled": True}):
async for obj in db.member.find({"enabled": True}):
allowed_names.append(obj["_id"])
allowed_uids = []
async for obj in mongodb.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": True}, {"inventory.owner_id": True, "token.uid_hash": True }):
async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": True}, {"inventory.owner_id": True, "token.uid_hash": True }):
if obj["inventory"].pop("owner_id") in allowed_names:
del obj["_id"]
del obj["inventory"]
@ -50,7 +49,7 @@ async def view_longpoll(request):
}
]
try:
async with mongodb.eventlog.watch(pipeline) as stream:
async with db.eventlog.watch(pipeline) as stream:
await response.write("data: watch-stream-opened\n\n")
async for event in stream:
if event["fullDocument"].get("type") == "open-door":

6
overnode.yml

@ -0,0 +1,6 @@
id: doorboy
version: 3.7
app:
docker-compose.yml: 1, 2, 3
Loading…
Cancel
Save