Skip to content

Commit b8bf6d2

Browse files
Merge pull request #1164 from threefoldtech/development_update_socket_io
Update backend and frontend socket io clients
2 parents 7e1786c + 75404e6 commit b8bf6d2

18 files changed

Lines changed: 248 additions & 105 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: staging
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# - uses: actions/checkout@v1
12+
# - uses: actions/setup-java@v1
13+
# with:
14+
# java-version: '12.x'
15+
16+
# # Setup the flutter environment.
17+
# - uses: subosito/flutter-action@v1
18+
# with:
19+
# channel: 'stable' # 'dev', 'alpha', default to: 'stable'
20+
# flutter-version: '2.10.1' # you can also specify exact version of flutter
21+
22+
# # Get flutter dependencies.
23+
# - run: cd app && flutter pub get
24+
25+
# # Check for any formatting issues in the code.
26+
# - run: flutter format --set-exit-if-changed .
27+
28+
# # Statically analyze the Dart code for any errors.
29+
# - run: flutter analyze .
30+
31+
# # Build apk.
32+
# - run: flutter build apk
33+
34+
# # Upload generated apk to the artifacts.
35+
# - uses: actions/upload-artifact@v1
36+
# with:
37+
# name: release-apk
38+
# path: app/apks/app-release.apk
39+
40+
- uses: actions/checkout@v2
41+
- name: Login to docker hub
42+
run: docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }}
43+
- name: Set config
44+
run: mv frontend/public/config.staging.js frontend/public/config.js
45+
- name: Build the Docker image
46+
run: docker build . --file Dockerfile --tag jimber/3botlogin:staging-${{ github.sha }}
47+
- name: Push the Docker image
48+
run: docker push jimber/3botlogin:staging-${{ github.sha }}
49+
50+
deploy:
51+
needs: build
52+
runs-on: tfc-connect-staging
53+
steps:
54+
- name: Login to docker hub
55+
run: docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }}
56+
- name: kill old docker
57+
run: docker rm -f 3botlogin || true
58+
- name: Pull Image
59+
run: docker pull jimber/3botlogin:staging-${{ github.sha }}
60+
- name: Run new docker
61+
run: docker run -d -it --restart=unless-stopped --name 3botlogin -v /opt/3botlogin/pythonsqlite.db:/usr/share/nginx/backend/pythonsqlite.db -v /opt/3botlogin/config.ini:/usr/share/nginx/backend/config.ini --network=proxy jimber/3botlogin:staging-${{ github.sha }}

.github/workflows/old_wfs/testing.yml

Whitespace-only changes.

.github/workflows/staging.yml

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,33 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
# - uses: actions/checkout@v1
12-
# - uses: actions/setup-java@v1
13-
# with:
14-
# java-version: '12.x'
15-
16-
# # Setup the flutter environment.
17-
# - uses: subosito/flutter-action@v1
18-
# with:
19-
# channel: 'stable' # 'dev', 'alpha', default to: 'stable'
20-
# flutter-version: '2.10.1' # you can also specify exact version of flutter
21-
22-
# # Get flutter dependencies.
23-
# - run: cd app && flutter pub get
24-
25-
# # Check for any formatting issues in the code.
26-
# - run: flutter format --set-exit-if-changed .
27-
28-
# # Statically analyze the Dart code for any errors.
29-
# - run: flutter analyze .
30-
31-
# # Build apk.
32-
# - run: flutter build apk
33-
34-
# # Upload generated apk to the artifacts.
35-
# - uses: actions/upload-artifact@v1
36-
# with:
37-
# name: release-apk
38-
# path: app/apks/app-release.apk
39-
4011
- uses: actions/checkout@v2
41-
- name: Login to docker hub
42-
run: docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }}
12+
- name: Log into Docker Hub
13+
uses: docker/login-action@v2
14+
with:
15+
username: ${{ secrets.TFDOCKERHUB_USERNAME }}
16+
password: ${{ secrets.TFDOCKERHUB_PASSWORD }}
17+
4318
- name: Set config
4419
run: mv frontend/public/config.staging.js frontend/public/config.js
45-
- name: Build the Docker image
46-
run: docker build . --file Dockerfile --tag jimber/3botlogin:staging-${{ github.sha }}
47-
- name: Push the Docker image
48-
run: docker push jimber/3botlogin:staging-${{ github.sha }}
49-
20+
- name: Build the 3botlogin Docker image
21+
run: docker build . --file Dockerfile --tag threefolddev/3botlogin:staging-${{ github.sha }}
22+
- name: Push the 3botlogin Docker image
23+
run: docker push threefolddev/3botlogin:staging-${{ github.sha }}
24+
- name: Build wizard Docker image
25+
run: docker build wizard/ --file wizard/Dockerfile --tag threefolddev/wizard:staging-${{ github.sha }}
26+
- name: Push wizard Docker image
27+
run: docker push threefolddev/wizard:staging-${{ github.sha }}
28+
5029
deploy:
51-
needs: build
52-
runs-on: tfc-connect-staging
30+
needs: [build]
31+
runs-on: ubuntu-latest
5332
steps:
54-
- name: Login to docker hub
55-
run: docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }}
56-
- name: kill old docker
57-
run: docker rm -f 3botlogin || true
58-
- name: Pull Image
59-
run: docker pull jimber/3botlogin:staging-${{ github.sha }}
60-
- name: Run new docker
61-
run: docker run -d -it --restart=unless-stopped --name 3botlogin -v /opt/3botlogin/pythonsqlite.db:/usr/share/nginx/backend/pythonsqlite.db -v /opt/3botlogin/config.ini:/usr/share/nginx/backend/config.ini --network=proxy jimber/3botlogin:staging-${{ github.sha }}
33+
- uses: actions/checkout@v2
34+
- name: Set authorization certificate
35+
run: |
36+
mkdir ${HOME}/.kube
37+
echo ${{ secrets.TF_KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config
38+
- name: Install or Upgrade production on cluster
39+
run: |
40+
helm upgrade threebotlogin --install helm_files -f helm_files/valuesStaging.yaml --set images.login.tag=staging-${{ github.sha }} --set images.wizard.tag=staging-${{ github.sha }} -n threefoldconnect-staging

Dockerfile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12 as builder
1+
FROM node:16 AS builder
22

33
COPY frontend /frontend
44
WORKDIR /frontend
@@ -13,16 +13,26 @@ WORKDIR /wizard
1313
RUN yarn install --frozen-lockfile && yarn build
1414

1515

16-
FROM nginx:1.21.1
16+
FROM nginx:1.25
1717
COPY backend/requirements.txt requirements.txt
1818

19-
RUN apt update && apt install -y python3 python3-pip gcc libssl-dev python-gevent
20-
RUN CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" \
21-
UWSGI_PROFILE_OVERRIDE=ssl=true pip3 install uwsgi==2.0.19.1 -Iv
22-
# RUN pip3 install flask flask_socketio flask_cors pyfcm pynacl
23-
RUN pip3 install --upgrade pip
24-
RUN pip3 install -r requirements.txt --ignore-installed
25-
RUN pip3 install gevent
19+
RUN apt-get update && apt-get install -y \
20+
python3 \
21+
python3-pip \
22+
gcc \
23+
libssl-dev \
24+
python3-dev \
25+
libffi-dev \
26+
&& rm -rf /var/lib/apt/lists/*
27+
RUN pip3 install --break-system-packages uwsgi==2.0.26
28+
RUN pip3 install --break-system-packages --upgrade pip
29+
# Install stellar-sdk first to get compatible yarl version
30+
RUN pip3 install --break-system-packages stellar-sdk==9.1.0
31+
# Increase timeout and retries for slow network connections
32+
RUN pip3 install --break-system-packages \
33+
--default-timeout=100 \
34+
--retries=5 \
35+
-r requirements.txt --ignore-installed
2636

2737
COPY --from=builder /frontend/dist /var/www/html/frontend
2838
# COPY --from=builder /example/dist /var/www/html/example
@@ -35,4 +45,4 @@ COPY services.sh /services.sh
3545
RUN chmod +x /services.sh
3646
WORKDIR /usr/share/nginx/backend/
3747

38-
CMD /./services.sh
48+
CMD ["/services.sh"]

backend/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
logging.getLogger("engineio").setLevel(level=logging.ERROR)
3131

3232
# check_blockchain()
33-
sio.init_app(app, cors_allowed_origins="*")
33+
sio.init_app(app)
3434

3535
if __name__ == "__main__":
3636
sio.run(app, host="0.0.0.0", port=5000)

backend/requirements.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ entrypoints==0.3
99
Flask==2.0.1
1010
Flask-Cors==3.0.10
1111
Flask-RESTful==0.3.9
12-
Flask-SocketIO==4.3.2
13-
gevent==21.1.2
14-
greenlet==1.1.0
12+
Flask-SocketIO==5.3.6
13+
gevent==24.2.1
14+
greenlet==3.0.3
15+
gevent-websocket==0.10.1
1516
idna==2.10
1617
itsdangerous==2.0.1
1718
Jinja2==3.0.1
@@ -24,17 +25,17 @@ pycparser==2.20
2425
pycrypto==2.6.1
2526
pyfcm==1.5.3
2627
PyNaCl==1.4.0
27-
python-engineio==3.14.2
28-
python-socketio==4.6.1
28+
python-engineio==4.9.0
29+
python-socketio==5.11.0
2930
pytz==2021.1
3031
pyxdg==0.27
31-
requests==2.25.1
32+
requests==2.31.0
3233
requests-toolbelt==0.9.1
3334
SecretStorage==3.3.1
3435
six==1.15.0
3536
SQLAlchemy==1.4.22
36-
urllib3==1.26.4
37-
uWSGI==2.0.19.1
37+
urllib3==2.0.7
38+
uWSGI==2.0.26
3839
Werkzeug==2.0.1
39-
stellar-sdk==3.3.1
40+
stellar-sdk==9.1.0
4041
nanoid==2.0.0

backend/routes/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@api_misc.route("/minimumversion", methods=["get"])
1111
def minimum_version_handler():
1212
response = Response(
13-
response=json.dumps({"android": 184, "ios": 183}), mimetype="application/json"
13+
response=json.dumps({"android": 195, "ios": 195}), mimetype="application/json"
1414
)
1515
return response
1616

backend/services/socket.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
import database as db
77
from services.logger import logger
88

9-
sio = SocketIO(transports=["websocket"])
9+
sio = SocketIO(
10+
cors_allowed_origins="*",
11+
async_mode='gevent_uwsgi',
12+
logger=False,
13+
engineio_logger=False,
14+
ping_timeout=60,
15+
ping_interval=25,
16+
allow_upgrades=True,
17+
)
1018

1119
usersInRoom = {}
1220
messageQueue = {}

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"axios": "^1.8.2",
14+
"socket.io-client": "^4.7.5",
1415
"bip39": "^2.5.0",
1516
"libsodium": "^0.7.6",
1617
"libsodium-wrappers": "^0.7.6",

frontend/public/config.staging.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default ({
2-
apiurl: 'https://login.staging.jimber.io/',
3-
openkycurl: 'https://openkyc.staging.jimber.io/',
2+
apiurl: 'https://login.staging.threefold.me/',
3+
openkycurl: 'https://kyc.staging.threefold.me/',
44
deeplink: 'threebot-staging://'
55
})

0 commit comments

Comments
 (0)