-
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
Showing
48 changed files
with
29,790 additions
and
1 deletion.
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,29 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.x' | ||
- name: Deploy source code | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_DEPLOY_HOST }} | ||
username: ${{ secrets.SSH_DEPLOY_USER }} | ||
key: ${{ secrets.SSH_DEPLOY_KEY }} | ||
port: ${{ secrets.SSH_DEPLOY_PORT }} | ||
script: | | ||
(git clone ssh://[email protected]/${{ github.repository }} -b ${{ github.ref_name }} source) || (cd source && git pull) | ||
cd source && docker-compose --env-file .env -f docker/docker-compose.prod.yml up -d --build |
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 @@ | ||
.DS_Store | ||
tags | ||
.tern_port | ||
tags.* | ||
node_modules | ||
desktop.ini | ||
.vscode | ||
.vim | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
install-deps: | ||
cd backend; \ | ||
python3 -m pip install -r requirements-dev.txt; \ | ||
cd ../frontend; \ | ||
npm install | ||
|
||
docker-run-dev: | ||
docker-compose -f docker/docker-compose.yml up --build | ||
|
||
docker-run-prod: | ||
docker-compose -f docker/docker-compose.prod.yml up |
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,104 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
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,13 @@ | ||
FROM python:3.9 as dev | ||
|
||
WORKDIR /app | ||
|
||
COPY ./requirements/ ./requirements | ||
RUN cd requirements && pip install --no-cache-dir -r development.txt | ||
|
||
CMD ["python3", "app.py"] | ||
|
||
# base image | ||
FROM dev as prod | ||
|
||
COPY . /app |
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,103 @@ | ||
PROJECT_NAME=meetx | ||
TIME=60 | ||
|
||
# colors | ||
GREEN = $(shell tput -Txterm setaf 2) | ||
YELLOW = $(shell tput -Txterm setaf 3) | ||
WHITE = $(shell tput -Txterm setaf 7) | ||
RESET = $(shell tput -Txterm sgr0) | ||
GRAY = $(shell tput -Txterm setaf 6) | ||
TARGET_MAX_CHAR_NUM = 20 | ||
|
||
# Common | ||
|
||
all: run | ||
|
||
## Runs application. Builds, creates, starts, and attaches to containers for a service. | Common | ||
run: | ||
@docker-compose up $(PROJECT_NAME)_app | ||
|
||
## Rebuild meetx_app container | ||
build: | ||
@docker-compose build $(PROJECT_NAME)_app | ||
|
||
## Stops application. Stops running container without removing them. | ||
stop: | ||
@docker-compose stop | ||
|
||
## Removes stopped service containers. | ||
clean: | ||
@docker-compose down | ||
|
||
## Runs command `bash` commands in docker container. | ||
bash: | ||
@docker exec -it $(PROJECT_NAME) bash | ||
|
||
## Upgrade your python's dependencies: | ||
upgrade: | ||
docker-compose run --rm $(PROJECT_NAME)_app python3 -m $(PROJECT_NAME).utils.check-requirements | ||
|
||
## Create profile sampling of application. | ||
profile: | ||
@docker exec -it $(PROJECT_NAME) py-spy record -d $(TIME) -o $(PROJECT_NAME)_profile.svg --pid 7 | ||
|
||
# Help | ||
|
||
## Shows help. | ||
help: | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo '' | ||
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}' | ||
@echo '' | ||
@echo 'Targets:' | ||
@awk '/^[a-zA-Z\-\_]+:/ { \ | ||
helpMessage = match(lastLine, /^## (.*)/); \ | ||
if (helpMessage) { \ | ||
if (index(lastLine, "|") != 0) { \ | ||
stage = substr(lastLine, index(lastLine, "|") + 1); \ | ||
printf "\n ${GRAY}%s: \n\n", stage; \ | ||
} \ | ||
helpCommand = substr($$1, 0, index($$1, ":")-1); \ | ||
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ | ||
if (index(lastLine, "|") != 0) { \ | ||
helpMessage = substr(helpMessage, 0, index(helpMessage, "|")-1); \ | ||
} \ | ||
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ | ||
} \ | ||
} \ | ||
{ lastLine = $$0 }' $(MAKEFILE_LIST) | ||
@echo '' | ||
|
||
# Docs | ||
|
||
## Generate html documentation. | Documentation | ||
doc: | ||
@docker-compose run --rm $(PROJECT_NAME)_app make _doc | ||
|
||
_doc: | ||
@doc8 docs | ||
@cd docs && make html | ||
|
||
# Linters & tests | ||
|
||
## Formats code with `black`. | Linters | ||
black: | ||
black $(PROJECT_NAME) -l 79 | ||
|
||
## Checks types with `mypy`. | ||
mypy: | ||
@docker-compose run --rm $(PROJECT_NAME)_app mypy $(PROJECT_NAME) | ||
|
||
## Formats code with `flake8`. | ||
lint: | ||
@docker-compose run --rm $(PROJECT_NAME)_app flake8 $(PROJECT_NAME) | ||
|
||
## Runs tests. | Tests | ||
test: lint | ||
@docker-compose up test | ||
@docker-compose stop test | ||
|
||
## Runs application with development config. | ||
adev: | ||
adev runserver ./$(PROJECT_NAME)/__main__.py -p 8080 |
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 @@ | ||
import aiohttp | ||
from aiohttp import web | ||
import socketio | ||
|
||
sio = socketio.AsyncServer( | ||
cors_allowed_origins="*", async_mode="aiohttp", async_handlers=True | ||
) | ||
app = web.Application() | ||
sio.attach(app, socketio_path="api/socket.io") | ||
|
||
|
||
async def index(request): | ||
return web.Response( | ||
body=aiohttp.JsonPayload({}), content_type="application/json" | ||
) | ||
|
||
|
||
@sio.on("join") | ||
async def join(sid, data): | ||
print("join", data) | ||
room_id = data["roomId"] | ||
sio.enter_room(sid, room_id) | ||
sockets = sio.manager.rooms["/"].get(room_id, []) | ||
if len(sockets) == 1: | ||
await sio.emit("init", to=sid) | ||
elif len(sockets) == 2: | ||
await sio.emit("ready", room=room_id) | ||
else: | ||
await sio.emit("full", to=sid) | ||
|
||
|
||
@sio.on("signal") | ||
async def handle_signal(sid, data): | ||
room_id = data["roomId"] | ||
|
||
await sio.emit("signal", data["signal"], room=room_id) | ||
|
||
|
||
@sio.on("kick") | ||
async def handle_kick(sid, data): | ||
room_id = data["roomId"] | ||
await sio.emit("kick", room=room_id, skip_sid=sid) | ||
|
||
|
||
@sio.on("disconnect") | ||
async def disconnect(sid): | ||
rooms = sio.rooms(sid) | ||
for room in rooms: | ||
sio.leave_room(sid, room) | ||
await sio.emit("disconnected", room=room) | ||
|
||
|
||
if __name__ == "__main__": | ||
web.run_app(app, host="0.0.0.0", port=5000) |
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 @@ | ||
[mypy] | ||
ignore_missing_imports = True | ||
|
||
check_untyped_defs = True | ||
disallow_any_generics = True | ||
disallow_untyped_defs = True | ||
follow_imports = silent | ||
strict_optional = True | ||
warn_redundant_casts = True | ||
warn_unused_ignores = True |
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,12 @@ | ||
-r production.txt | ||
|
||
mypy==0.920 | ||
flake8==4.0.1 | ||
pytest==6.2.5 | ||
pytest-cov==3.0.0 | ||
pytest-aiohttp==0.3.0 | ||
black==21.12b0 | ||
py-spy==0.3.11 | ||
|
||
aiohttp-devtools==0.13.1 | ||
aiohttp-debugtoolbar==0.6.0 |
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,5 @@ | ||
aiohttp==3.8.1 | ||
aiohttp_jinja2==1.5 | ||
trafaret_config==2.0.2 | ||
markdown2==2.4.2 | ||
python-socketio==5.5.1 |
Oops, something went wrong.