Tuesday, 19 July 2022

docker with django python3 and mysql fresh init look out

 1) download for git

2)  hdjangoDemo/init/mysql ensure mysql/ has docker group with permission 750 - for successful docker compose up because its gonna run this script to grant permission to docker test user to create test table

* also folder will be mapped to /docker-entrypoint-initdb.d, docker needs to have group permission to access, some server set up is different, it will require 755 permission 5(r+e for other as docker ended up in other groups)

3) creaet ~/nySqlData folder with docker group permission 750 I.E user:docker (to be mapped to docker mysql)

4) ensure .bash_profile :

# Export current user UID and GID exported for docker                                                                                          

export gID="$(id -u)"                                                                                                                                                                                                                                    

export uID="$(id -g)"      

5) run test ensure everything is ok docker-compose run app sh -c "python manage.py test"

6) app/app/settings.py ALLOWED_HOSTS need to add ur local IP for internal routing and calls.

7) docker-compose build

8) If no migration file in core/migrations, run  docker-compose run app sh -c "python manage.py makemigrations core" (docker-compose run app sh -c "python manage.py test" to ensure test still passes(optional))

9) docker-compose up 

10) if docker failed to start, comment out app service in docker-compose.yml to check db service


******changing git branch will mess up permission and groups, need to set chmod 755 to all files ***

**unfortunately it ended up needing 5 on other permission **more detail will be followed once root cause is found**


No comments:

Post a Comment