Pand-Aid / pandaid-api

backend for Pand-Aid pandemic response app
3 stars 3 forks source link

Dev tools #11

Closed geophpherie closed 4 years ago

geophpherie commented 4 years ago

name: Dev Tools syntax about: Structure for additional dev tools scripts and docker exec syntax.

What does this do and why?

Moves the existing manage.py commands to using docker exec instead of docker-compose run. This allows for attaching to running containers with the shell, rather than spinning up a separate container. I think this is what we want. Adds support for a psql command. Also includes some README.md changes to explain how to use. The docker-compose run syntax is left in (commented out) for use if we need it.

This closes #5. Any new requests for convenience scripts should be opened as new issues.

Additional notes for reviewers

Containers must be running with docker-compose up for these to work.

Pre-Review Tasks

Place an ‘x’ between the brackets.

[x] I wrote tests covering these changes -N/A

[x ] I reviewed my own PR before asking for review from others

[x ] I added PR comments providing additional context for reviewers where appropriate, or calling attention to especially sensitive changes.

[x ] If deps were added, I verified the licenses - N/A

Verification steps

README.md here has instructions on running on both mac and win. Wouldn't mind someone taking a second look to ensure the win version is running properly.

Screenshots (if appropriate)

Expected outcome on mac:

jeff@ 🦠 ~/Repos/pandaid-api/dev/mac $ ./run_psql.sh 
psql (11.6 (Debian 11.6-1.pgdg90+1))
Type "help" for help.

postgres=# \q
jeff@ 🦠 ~/Repos/pandaid-api/dev/mac $ ./manage_py.sh shell
Python 3.8.2 (default, Feb 26 2020, 14:58:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: quit()                                                                                                                                                                                                                                                                                                                     
jeff@ 🦠 ~/Repos/pandaid-api/dev/mac $ 
geophpherie commented 4 years ago
  1. The original ticket suggested using docker-compose run so I started with that. There's really only one version though, using docker exec commands. I left the docker-compose run ones in commented out for reference.
  2. I've run the Mac ones using bash, so I'd think they could work for linux?
  3. I changed it from %1 to %* to pull in additional args if desired. So not limited to 1.
znmeb commented 4 years ago
2. I've run the Mac ones using bash, so I'd think they could work for linux?

I'll try them - I've got Linux booted at the moment.

  1. I changed it from %1 to %* to pull in additional args if desired. So not limited to 1. What would you do with the extra arguments? Do the scripts even use the arguments? Do they check that all required arguments are present?
geophpherie commented 4 years ago

It's really just a pass through to the underlying call. So if you would run manage.py with multiple args, it'll send them to it. If you pass the wrong values or not enough, it'd be the same as calling it directly the incorrect way. Same with psql

znmeb commented 4 years ago

Ah, OK. Meanwhile, the mac ones work on Linux so the easy thing would be to change the directory name to mac-or-linux. :-)

geophpherie commented 4 years ago

okay I can do that quick before we merge.