This is my solution for the assessment presented HERE!
- Docker
- Nginx (prod)
- Gunicorn (prod)
- PostgreSQL or possibly others SQL Databases
- Python
- Packages:
- Django
- Django Rest Framework
- More Details on requirements.txt
Do you have Docker Installed?
When web container start, on the first time, the follow commands are executed automatically:
python manage.py flush --no-input
python manage.py makemigrations
python manage.py migrate --noinput
python manage.py loaddata users.json posts.json reposts.json quote-postings.json
Getting ready the database and loading some example data, so NO NEED TO EXECUTE the commands ABOVE.
They are included on entrypoints scripts: entrypoint.sh and entrypoint.prod.sh.
But if wanted on your own risk it's possible to execute using:
docker-compose -f docker-compose.prod.yml exec web python manage.py flush --noinput
docker-compose -f docker-compose.prod.yml exec web python manage.py makemigrations
docker-compose -f docker-compose.prod.yml exec web python manage.py migrate --noinput
docker-compose -f docker-compose.prod.yml exec web python manage.py loaddata customers.json staff.json rooms.json events.json
INFO: we are not putting migrations on version control because this is a fresh start project.
Usually we put migrations on version control when we have a older project or a project where we expect to grow.
-
docker-compose build --no-cache
-
docker-compose up -d
-
docker-compose down -v
-
username: superuser password: password admin url: http://localhost:8000/admin
-
docker-compose down -v
-
docker-compose -f docker-compose.prod.yml up -d --build
-
FINALLY OPEN http://localhost:1337/
-
docker-compose -f docker-compose.prod.yml down -v
-
username: superuser password: password username: staff password: password admin url: http://localhost:8000/admin
On DEV Environment tests are executed on every container start see entrypoint.sh and a test.log file is generated,
to run on demand see the commands bellow:
-
docker-compose exec web python manage.py test small_business.rooms small_business.events
-
docker-compose -f docker-compose.prod.yml exec web python manage.py test small_business.rooms small_business.events
Use notepad++, go to edit -> EOL conversion -> change from CRLF to LF.
update: For VScode users: you can change CRLF to LF by clicking on CRLF present on lower right side in the status bar
https://stackoverflow.com/questions/51508150/standard-init-linux-go190-exec-user-process-caused-no-such-file-or-directory
E-mail: [email protected]
Thank you for your time, and I hope we can talk in near future.