A private BitTorrent tracker written with Python, Django, Redis, and React.
223
cp .env.template .env and then set and save these. Make sure
to run the command inside the frontend folder too.Once that is complete you can build the project. For the production server, to test production, or if you are not using docker, there is an .env.template file in the backend folder that should be updated as well.
docker-compose build to build the imagesdocker-compose run --rm api invoke setup-db to create the db
tables and load in some development datadocker-compose run --rm api python src/manage.py passwd admin
to set yourself a password for the admin userdocker-compose run --rm api python src/manage.py createsuperuser
for a new user accountdocker-compose up to start everything, and visit to log inThese commands will build all the containers and set up the database with our core fixtures. This may take a while, but afterwards subsequent commands will be much faster.
There are two ways of running common commands. The jc.sh script is
responsible for things to do with docker (running, building images) and
invoke (sort of like Make, for python) is used within the server to
run commands. Django manage.py is also useful. Both invoke and
manage.py are accessible from the jc.sh script.
To list jc.sh commands:
./jc.sh
To list invoke commands:
./jc.sh i -l
./jc.sh i test
To list manage.py commands:
./jc.sh m
./jc.sh m passwd admin
./jc.sh runserver
You can find the api/django-admin server on , the frontend server on and the tracker server on .
For example, here is an announce request that will work with the fixture
data that was loaded in by the setup-db command:
http://localhost:7070/16fd2706-8baf-433b-82eb-8c7fada847da/announce/?info_hash=%89I%85%F9%7C%C2%5C%24n7%A0%7C%D7%C7%85%999%82%A7%CB&peer_id=-UT3400-111122221111&uploaded=721&downloaded=982&left=0&port=1337&ip=192.168.1.4
If you change
a) The python requirements file in backend b) Any frontend files not in frontend/src/ including the javascript requirements file
you need to rebuild your local containers by running:
./jc.sh build
There is no need to do this if you just change the source code for either the frontend or backend (they are on docker volumes and changes should be loaded immediately)
Install Docker for Windows and set it up to use linux containers. You will have to [share the drive <https://docs.docker.com/docker-for-windows/#shared-drives>]{.title-ref}__ where you have the git repository.
From then on you can follow the instructions using your favourite command prompt.
Note that if you are using windows, due to the way the docker volume mounter handles file permissions, you will have to type
docker-compose run api python src/manage.py
instead of
docker-compose run api src/manage.py
in the following instructions.
I have added a shell script that can be run in the **Ubuntu for Windows Bash** running on the Windows Subsystem for Linux (WSL) to configure Bash for development using commandline Docker and Git commands in Windows 10.
Instructions for installing the Windows Subsystem for Linux on Windows 10 and Ubuntu for Windows can be found at the official WSL website:
https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
(The installation may require a system restart)
Once installation is complete, you should be able to start Ubuntu for Windows from the start menu. This project also includes an example shortcut for starting Ubuntu Bash.
Instructions for installing Docker for Windows can be found at the official Docker website:
https://store.docker.com/editions/community/docker-ce-desktop-windows
(The installation may require a system restart to enable Hyper-V)
Once Docker for Windows has been installed, you will need to configure it so that it can be accessed from the WSL bash.
Git comes installed by default with Ubuntu for Windows. You can clone this repository immediately from your WSL Bash by running:
git clone [email protected]:jumpcut/jumpcut.git
Make sure you have added your ssh key to git.
Once the code has been cloned you can run wsl.sh to configure your WSL
Bash to be able to communicate with Docker for Windows and install a
git-enabled commandline prompt that makes it easier to work with git
from WSL.
cd jumpcut
chmod +x ./scripts/wsl.sh
./scripts/wsl.sh
The shell script:
DOCKER_HOST environment variable in .bashrc to allow
docker to connect to Docker for WindowsYou should be able to run docker and docker-compose commands from
the WSL Ubuntu commandline on Windows as well as see git branch
information in the command prompt.
You can test them by running:
docker info
docker-compose version
docker run hello-world
To start you need to install the following:
Python 3.6.5: https://www.python.org/ftp/python/3.6.5/python-3.6.5-amd64.exe
make sure you edit your environment variables so you can call python, and pip.
I recommend using Windows PowerShell for most commands.
Install Postgresql: choco install postgresql
Install Redis for windows: https://github.com/MicrosoftArchive/redis/releases
You should then have postgresql installed. Make sure you set the postgresql database to the new .env file you have. Password, DB, etc.
pip3 install virtualenvwrapper-winNow you can create a new virtual environment with the mkvirtualenv command. As this command runs you'll see the environment being set up (what you see is slightly platform specific). When the command completes the new virtual enviroment will be active --- you can see this because the start of the prompt will be the name of the environment in brackets (as shown below).
`mkvirtualenv my_django_environment`
`From now on in this README (and indeed the module) please assume that any commands are run within a Python virtual environment like the one we set up above.`
Now use the install script, I have added a new file at the backend folder of the project, make sure your virtual environment is activated first!!!.
`cd backend`
`python -m pip install -r requirements.txt (now pip automatically will not install UWSGI)`
`python -m pip install -r testing_requirements.txt`
cd into the src folder and run the following before running the server:
python manage.py makemigrations
python manage.py migrate
python manage.py loaddata foundation
python manage.py loaddata dev
python manage.py collectstatic --noinput
python manage.py runserver_plus 0.0.0.0:8000
I have updated the index.html file for it to work locally for everyone. Before you run "Collectstatic", make sure and copy the index.html, and bundle files from the folder here:
/backend/src/gulpfiles
Copy them to the folder labelled: static/frontend.
You can overwrite these files in the directory locally.
./jc.sh i reset-dbThis command resets the db and loads the core fixtures to revert to a starting state.
Currently the admin user password it creates is hashed and salted using argon2. It is recommended that you use the function:
./jc.sh m passwd adminTo enter a new password for testing.
Content type
Image
Digest
Size
234.7 MB
Last updated
about 8 years ago
docker pull streisandjumpcut/streisand-api