- Docker and docker-compose
- Python 3.11
- UV. If not installed, run
pip install uv
docker compose up -d
This should create and set up the Mongo and Postgres databases.
Open source note: you'll need data for the entire project to work, which I do not provide
- Run
uv syncto activate the virtual environment - Comment out api service and
docker-compose up -d - Run vscode debugger to start the FastAPI application
- For tests:
make testor use.vscodefolder config - Install new dependencies with:
uv add <package-name> - Formatting with
make format - Upgrade pybinbot
make upgrade-pybinbot
- Run
npm run install:clean - Run
npm start - Attach vscode debugger if needed
npm run buildto test a production bundle locallynpm run testto run unit testsnpm run formatto prettier format files, although this should be set up with the vscode prettier plugin
- Merge changes to master
- Test on local:
cd terminal && npm start- Build and test docker container
docker build --tag binbot . && docker run -ti -p 8000:80 binbot - Publish to docker hub
docker build --tag binbot . && docker tag binbot carloswufei/binbot:latest && docker push carloswufei/binbot
- Wait for check to pass. Github action will publish to Docker Hub
If docker-compose doesn't exist: 3. Copy scp docker-compose.yml <USERNAME>@<SERVER_IP>:/var/www/binbot.carloswu.com
4. Modify details to match production needs
or docker build --tag binbot . && docker tag binbot carloswufei/binbot:latest && docker push carloswufei/binbot
In production:
5. docker compose up --pull always -d
6. If .env.prod is modified, scp to remote server and replace .env in production with new .env.prod
- Run
docker build --tag binbot . - Run
docker-compose up
If issues are encountered downloading prod DB to local
- Dump database:
docker exec binbot_db sh -c 'mongodump --authenticationDatabase admin -u <user> -p <password> --db binbot --archive' > db.dump - On local, restore
docker exec -i binbot_db sh -c 'mongorestore --archive -u <MONGO_AUTH_USERNAME> -p <MONGO_AUTH_PASSWORD> --authenticationDatabase <MONGO_AUTH_DATABASE> ' < db.dump
Everytime the application runs, it will alembic upgrade head. To rollback changes use alembic downgrade -1.
If files have been modified in the models and no new revisions were created, the Alembic Github action check should fail. In which case, an upgrade and new revision is required.
alembic revision --autogenerate -m "alter commisions column to support Big integers"
If you don't want to populate, remove the
--autogenerateso you can write it yourself or ask AI to write it for you
Write the commands in the newly generated file and rerun FastAPI.
You can now also use make migrate .
alembic stamp 113eb73ebba8
where 113eb73ebba8 is the supposed last "good" migration that you want to revert to.