Skip to content

πŸ”½ Relivator: The Docker Edition (Backend) | Frontend: https://github.com/demiroo/relivator-docker-frontend | Stack: Docker, Python, FastAPI, fly.io flyctl, frontend health check and more 😊

License

Notifications You must be signed in to change notification settings

demiroo/relivator-docker-backend

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Relivator: The Docker Edition (Backend)

Frontend's Repo: https://github.com/blefnk/relivator-docker-frontend

Getting Started

Prerequisites

  • IDE (VSCode recommended)
  • Python (tested with 3.11.8 version)
  • Docker and Docker Compose (for containerized development and deployment)
  • For Windows only: Powershell 7

Installation

The paths below are an example, you can use any you like.

1. Clone the repository:

mkdir C:\B\S\reliverse && cd C:\B\S\reliverse # Windows
mkdir ~/Desktop/B/S/reliverse && cd ~/Desktop/B/S/reliverse # macOS/Linux
git clone https://github.com/blefnk/relivator-docker-backend.git
cd relivator-docker-backend

2. Create and activate a virtual environment:

Windows:

python -m venv C:\B\A\python\venv\main

macOS/Linux:

python -m venv ~/Desktop/B/A/python/venv/main

3. Configure workspace:

Then open project in VSCode > Ctrl+Shift+P > Terminal: Create New Terminal

Windows:

# Ctrl+Shift+P > Python: Select Interpreter > Enter interpreter path
# Find... > And choose python.exe in C:\B\A\python\venv\main\Scripts
C:\B\A\python\venv\main\Scripts\activate.ps1 # Or use .bat when CMD

macOS/Linux:

source ~/Desktop/B/A/python/venv/main/bin/activate

4. Install dependencies:

The project already has many pre-selected good packages, so you can easily get started, or removeΒΉ unused packages whenever you want.

So, to install the packages listed in requirements.txt just run:

cd backend && pip install -r requirements.txt
ΒΉπŸ’‘ How to remove unused packages?

Here are the most common and effective ways to remove unused packages from the requirements.txt file:

1. Manual Review and Editing:

  • Best for small projects: If you already have a relatively short requirements.txt file, you can often manually go through it and identify packages that are no longer actively used in your code.
  • Time-consuming for larger projects: This becomes less practical as your project and the list of dependencies grow.

2. Automated Tools:

These tools analyze your project's code to help determine unused dependencies. Here are some popular options:

  • pip-autoremove:
    • Install: pip install pip-autoremove
    • Usage: pip-autoremove requirements.txt -o requirements.txt (This overwrites your original file)
  • pipdeptree (with reverse flag):
    • Install: pip install pipdeptree
    • Usage:
    • pipdeptree -r > possible_unused.txt  # Creates a list of possible unused packages
      # Manually review possible_unused.txt and edit requirements.txt
      
  • Other Tools:
    • pip-unused: A simple command-line tool.
    • There may be similar plugins for your IDE or code editor.

Important Considerations:

  • Caution: Automated tools can be helpful but they might not be 100% accurate. It's always best to double-check and test your project after removing packages from requirements.txt.
  • Version Conflicts: Sometimes packages might remain indirectly necessary due to dependencies of other required packages. Be mindful of complex dependencies when removing packages.

Workflow Example (Using pip-autoremove):

  1. Install pip-autoremove:
    pip install pip-autoremove
    
  2. Create a backup (optional, but recommended):
    cp requirements.txt requirements.txt.bak
    
  3. Remove unused packages:
    pip-autoremove requirements.txt -o requirements.txt
    
  4. Review Changes: Check the updated requirements.txt to make sure the automated tool didn't remove anything essential.
  5. Test Thoroughly: Run your project's tests or experiment with it manually to ensure everything still works as expected.

Development

Start the development server:

uvicorn main:app --reload
# http://localhost:10000
# http://localhost:10000/items/5?q=example

A tip!

Remember to work on the activate virtual environment after each new terminal with:

C:\B\A\python\venv\main\Scripts\activate.ps1 # .bat cmd, Windows
source ~/Desktop/B/A/python/venv/main/bin/activate # macOS/Linux

So you will see something like that:

  • Windows (main) PS C:\B\S\reliverse\relivator-docker-backend\backend >
  • macOS/Linux (main) user@machine:~/Desktop/B/S/reliverse/relivator-docker-backend/backend$

Deployment and dockerizing

Instructions for building and running the project using Docker are forthcoming.

Getting Things Ready:

  1. Install Docker Desktop and flyctl.
  2. Create an account with fly auth signup or login with fly auth login.
  3. Run fly launch from inside your project source directory to create, configure, and (for most apps) deploy a new application.
  4. If prompted, run fly deploy to deploy your new app (or to redeploy after changes!).

Contributing

Thanks for considering contributions to Reliverse, means to Relivator Universe, means to the one of main universe of Bleverse (Blefonix Multiverse)! 😍

  1. Follow the installation steps above, including deployment steps.
  2. Update requirements.txt if needed: pip freeze > requirements.txt.
  3. Make your changes. Ensure you have successful build with flyctl deploy.
  4. Commit the changes to your repo fork. Submit a PR to relivator-docker-backend.
  5. [optional] Visit and sign up on bleverse.com to collect your reward as a thank you. (You can win even Blefcoins or even Blefonix Stone!)

About

πŸ”½ Relivator: The Docker Edition (Backend) | Frontend: https://github.com/demiroo/relivator-docker-frontend | Stack: Docker, Python, FastAPI, fly.io flyctl, frontend health check and more 😊

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 93.8%
  • HTML 6.2%