Foodgram is a website with many functions, the main one of which is to share your recipes.
The full list of modules used in the project is available in backend/requirements.txt
Online Foodgram service and API for it. There is an implementation of the CI/CD project. In this service, users can publish recipes, subscribe to other users' publications, add their favorite recipes to Favorites, download a list of products needed to prepare one or more selected dishes.
- Guest (unauthorized user)
- Authorized user
- Administrator
- Create an account.
- View recipes on the main page.
- View individual recipe pages.
- View user pages.
- Filter recipes by tags.
- Log in with your username and password.
- Log out (log out).
- Change your password.
- Create/edit/delete your own recipes
- View recipes on the main page.
- View user pages.
- View individual recipe pages.
- Filter recipes by tags.
- Work with a personal favorites list: add recipes to it or delete them, view your favorites recipes page.
- Work with a personal shopping list: add/remove any recipes, upload a file with the number of necessary ingredients for recipes from the shopping list.
- Subscribe to recipe authors' publications and cancel your subscription, view your subscriptions page.
More information is available in the API documentation at http://localhost/api/docs/ after run the project.
Starts when executing the 'git push' command. Jobs:
- tests: Checking the code for compliance with the PEP8 standard (using the flake8 package)
- build_image_and_push_to_docker_hub: Build and push the project image on DockerHub.
- deploy: Automatic deployment of the project to the server.
- send_message: Sending a notification to the user in Telegram.
You must have installed and run Docker. More information in Instructions.
- Option 1. Use SSH:
git clone git@github.com:MrKalister/foodgram-project-react.git
- Option 2. Use HTTPS:
git clone https://github.com/MrKalister/foodgram-project-react.git
cd foodgram-project-react
Command to install a virtual environment on Mac or Linux:
python3 -m venv env
source env/bin/activate
Command for Windows:
python -m venv venv
. venv/Scripts/activate
cd infra
cp .env.example .env
DB_ENGINE=django.db.backends.postgresql # database DB_NAME=postgres # name database POSTGRES_USER=postgres # login for connect to database POSTGRES_PASSWORD=12345 # password for connect to database DB_HOST=db # name container with database DB_PORT=5432 # login for connect to database SECRET_KEY=12345 # secret key for Django project SQLITE_ENGINE = # default database(option)
docker-compose up -d
docker-compose exec backend bash
python manage.py makemigrations
python manage.py migrate
python manage.py shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()
python manage.py loaddata data/test_db.json
If you need create new admin:
python manage.py createsuperuser
open URL and enjoy. P.S. If you use for local mashine SQLlite and want download your database you can:
- Through the terminal, navigate to the project on the local computer.
- go to the directory where the file 'manage.py' is located.
- Export data in the file, example:
python manage.py dumpdata > dump.json
- Copy your file dump.json from the local computer to a remote server using scp.Run command:
scp dump.json <username>@<HOST>:/home/<username>/.../<dir_of_project_with_manage.py>/
For workflow to work correctly, you need to add environment variables to the Secrets of this repository on GitHub:
-
PostgreSQL = get from .env file
-
SECRET_KEY = get from .env file
-
DOCKER_USERNAME = username from DockerHub
-
DOCKER_PASSWORD = password from DockerHub
-
USER = username for log in to a remote server
-
HOST = ip adress of remote server
-
SSH_KEY = your private SSH key (to get use the command: cat ~/.ssh/id_rsa)
-
PASSPHRASE = if you specified the code to connect to the server via ssh
-
TELEGRAM_TO = your Telegram account id
-
TELEGRAM_TOKEN = your Telegram bot token
ssh <username>@<ip_address>
sudo apt install docker.io
sudo apt-get update
sudo apt-get install docker-compose-plugin
sudo apt install docker-compose
3. Being locally in the infra/ directory, copy the docker-compose files.yml and nginx.conf to a remote server.
scp docker-compose.yml <username>@<host>:/home/<username>/
scp nginx.conf <username>@<host>:/home/<username>/
This step can be skipped, in which case "sudo" must be specified at the beginning of each command
sudo usermod -aG docker username
docker-compose exec backend bash
python manage.py makemigrations
python manage.py migrate
python manage.py shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()
python manage.py loaddata data/test_db.json
If you need create new admin
python manage.py createsuperuser
open URL and enjoy.
Novikov Maxim - github