- Create .env with all settings (see .env.example)
- Collect static with
python manage.py collectstatic
- Run
docker-compose up --build
This method may need changes in some files/dirs paths and dns names to local ips.
- Install requirements and dev-requirements
- Create .env with all settings (see .env.example)
- Migrate db data with
python /app/manage.py migrate
- Collect static with
python manage.py collectstatic
- Choose server to run (uwsgi with
uwsgi --ini /app/uwsgi.ini
or django withpython /app/manage.py runserver 0.0.0.0:8000
)
Follow these steps to migrate data from db.sqlite to postgres (using Docker Compose method):
- Create /logs/load_data.log locally
- Build and up Docker Compose and enter django_webserver container terminal
- Run
export PYTHONPATH="/sqlite_to_postgres:${PYTHONPATH}"
- Run
python sqlite_to_postgres/load_data.py
You need to change DNS container names to local IPs for migrating data locally (and maybe some other settings).
There are possible errors that may occur if something went wrong. Here are some examples how to try fix them.
Sometimes you need to manually create /logs directory and needed .log files.
Sometimes may cause errors in postgres_model.py. Use scheme name on INSERT operations.
If Docker outputs errors about permissions then it may be caused by following things (most of):
- Unnamed volumes in docker-compose.yml
- Incorrect chown/chmod on some directories (ex. pgdata). Use your user + docker/postgres (or other group) and 700 rights (or even more protected) because some directories need to be chown by user who started server.
Возможные записи в сервисе db:
- "pgdata:/var/lib/postgresql/data"
- ./pgdata:/var/lib/postgresql/data # (instead use unnamed volume when troubles with permissions)
Также тк compose ищет переменные, указанные через $ в .env-файле по умолчанию рядом с .yml, необходимо указать его в корневой папке.
There are plenty of errors caused by incorrect paths (locally or in Docker). Be careful with Docker Compose volumes and .env file.