- Python 66.7%
- HTML 15.6%
- CSS 9.9%
- JavaScript 7.7%
- Dockerfile 0.1%
| apps | ||
| conf | ||
| core | ||
| locale | ||
| nginx | ||
| redis | ||
| templates | ||
| templatetags | ||
| tests | ||
| utils | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| AUTHORS | ||
| CHANGELOG.rst | ||
| docker-compose.dev.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile-dev | ||
| entrypoint.sh | ||
| LICENSE | ||
| manage.py | ||
| README.rst | ||
| requirements_pip.txt | ||
ALTRepo Frontend =============
ALTRepo Front is a web interface for the ALTRepo API.
LICENSE
GNU AGPLv3
Run Docker
Clone project:
$ git clone 'git_project_repository'Create configuration file .env:
DEBUG=False ALLOWED_HOSTS=*, SQLITE_URL=sqlite:///databases/altrepo_front.sqlite3 CACHE_FILE=filecache://django_cache LOGGING_LEVEL=DEBUG LOGGING_FILENAME=log/logging.log SECRET_KEY=9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05 SECRET_LOGIN=admin SECRET_PASSWORD=admin BASE_API_ADDRESS=https://rdb.altlinux.org API_ADDRESS_FOR_TESTS=http://beta-repodb-api.mskdc.altlinux.org APP_PORT_EXT=1337 ALLOWED_IP=127.0.0.1, AWS_S3_ENDPOINT_URL=URL for S3 Storage AWS_ACCESS_KEY_ID=Access key ID for S3 Storage AWS_SECRET_ACCESS_KEY=Secret access key ID for S3 Storage AWS_REGION_NAME=us-east-1 AWS_BUCKET_NAME=Bucket name TG_TOKEN=Telegram bot token TG_CHAT_ID=Telegram chat idBuild the images and spin up the containers:
#For production $ docker-compose -f docker-compose.yml up -d --build #For development $ docker-compose -f docker-compose.dev.yml up -d --buildIf the container fails to start, check for errors in the logs via:
docker-compose logs -fFirst we’ll need to create a user who can login to the admin site. Run the following command::
$ docker exec -it container_id python3 manage.py createsuperuser #Enter your desired username and press enter:: Username: admin #You will then be prompted for your desired email address:: Email address: admin@example.com #The final step is to enter your password. You will be asked to enter your password twice, the second time as a confirmation of the first. Password: ********** Password (again): ********* Superuser created successfully.
Run a local server
Clone project:
$ git clone 'git_project_repository'Create a Python ≥ 3.7 virtualenv:
$ python3 -m venv envInstall requirements:
# for pip $ source env/bin/activate $ pip3 install -r requirements/pip.txt #for altlinux $ apt-get install \ python3-module-asgiref \ python3-module-certifi \ python3-module-chardet \ python3-module-django \ python3-module-django-ckeditor \ python3-module-django-js-asset \ python3-module-gunicorn \ python3-module-idna \ python3-module-dateutil \ python3-module-pytz \ python3-module-requests \ python3-module-six \ python3-module-sqlparse \ python3-module-urllib3 \ python3-module-django-environ \ python3-module-django-gunicorn \If requirements install from altlinux.txt then change in the file env/pyvenv.cfg:
include-system-site-packages = trueCreate configuration file .env:
DEBUG=True ALLOWED_HOSTS=List of allowed hosts(specify comma-separated) SQLITE_URL=sqlite:///databases/altrepo_front.sqlite3 CACHE_FILE=filecache://django_cache LOGGING_LEVEL=DEBUG LOGGING_FILENAME=log/logging.log SECRET_KEY=Secret key for Django Project SECRET_LOGIN=Administrator login for api SECRET_PASSWORD=Administrator password for api BASE_API_ADDRESS=url api APP_PORT_EXT=8001 AWS_S3_ENDPOINT_URL=URL for S3 Storage AWS_ACCESS_KEY_ID=Access key ID for S3 Storage AWS_SECRET_ACCESS_KEY=Secret access key ID for S3 Storage AWS_REGION_NAME=us-east-1 AWS_BUCKET_NAME=Bucket name TG_TOKEN=Telegram bot token TG_CHAT_ID=Telegram chat idCreate database:
$ python3 manage.py migrateFirst we’ll need to create a user who can login to the admin site. Run the following command::
$ python3 manage.py createsuperuser #Enter your desired username and press enter:: Username: admin #You will then be prompted for your desired email address:: Email address: admin@example.com #The final step is to enter your password. You will be asked to enter your password twice, the second time as a confirmation of the first. Password: ********** Password (again): ********* Superuser created successfully.Populate the maintainers table using the command:
$ python3 manage.py scrapeStart the development server:
$ python3 manage.py runserver
Gunicorn + Nginx
Create a systemd socket file for Gunicorn:
$ nano /etc/systemd/system/gunicorn.socket [Unit] Description=gunicorn socket [Socket] ListenStream=/run/gunicorn.sock [Install] WantedBy=sockets.targetCreate a systemd service file for Gunicorn:
$ nano /etc/systemd/system/gunicorn.service [Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] WorkingDirectory=/path_to_app/altrepo_front ExecStart=--access-logfile - \ --workers 5 \ --bind unix:/run/gunicorn.sock \ altrepo_front.wsgi:application [Install] WantedBy=multi-user.targetStart and activate the Gunicorn socket:
$ systemctl start gunicorn.socket #Check the status of the process: $ systemctl status gunicorn.socketCreate a new server block in the Nginx sites-enabled directory:
$ nano /etc/nginx/sites-enabled.d/altrepo_front.conf server { listen 80; server_name 127.0.0.1; root /path_to_app/altrepo_front; access_log /path_to_app/altrepo_front/nginx_access.log; error_log /path_to_app/altrepo_front/nginx_error.log; #location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /path_to_app/altrepo_front; } location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://unix:/run/gunicorn.sock; } }
Run tests
Running fast tests:
python3 manage.py test tests --exclude-tag=slow --exclude-tag=seleniumRunning slow tests(Make a request to the api for all packages in the sisyphus branch):
python3 manage.py test tests --tag=slowRunning selenium tests:
python3 manage.py test tests --tag=seleniumRunning pytest:
python3 -m pytest tests/pytest/