moviegeek
moviegeek copied to clipboard
Run Moviegeek as a containerized app in Docker
Hi Kim!
I recently started working through Practical Recommender Systems as part of my work at Tumblr (I'm really enjoying it so far, thank you for the book!) and realized that the install process for the app could probably be made a bit more efficient so people don't encounter system incompatibilities or errors.
Right now, there are multiple steps that the user needs to run manually, in addition to manually generating the API key through the Movie Database, to get the app up and running. There's a way the user install experience can be a bit better.
The Issue
The install process for MovieGeek involved a lot of manual moving parts that made it easy to miss a step and incur version or operating system incompatibilities, even using an isolated virtual environment. Additionally, it took over 10 minutes to install locally. Putting both the Django database and the web app into a docker-compose file that starts and runs the two services within its own Docker container will solve the issue. I also made a few other small tweaks to optimize data imports and use libraries like requests instead of urlllib to make starting up easier.
What Was Changed
- [ ] Created a
Dockerfile
that installs a plain vanilla version of Python 3.6 and requirements.txt and moves all app work inside the Docker container - [ ] Created a
docker-compose.yml
file that runs the Dockerfile, creates adb
andweb
services that start up together, and then automatically performs the Django migrations (https://github.com/practical-recommender-systems/moviegeek/compare/master...veekaybee:dockerize?expand=1#diff-e45e45baeda1c1e73482975a664062aa56f20c03dd9d64a827aba57775bed0d3R17) and starts the web server with mapped environment variables to Postgres in the db service - [ ] modified the
populate_moviegeek.py
andpopulate_ratings.py
scripts to load data into Postgres more quickly usingbulk_uploads
(https://github.com/practical-recommender-systems/moviegeek/compare/master...veekaybee:dockerize?expand=1#diff-012d668550df5c86490e59e735fc773a34f64084aa0a60ca75e20f28622cb99bR45) and output the tqdm logs todocker-logs
for visibility during install - [ ] modified the
populate
scripts to use the more standardrequests
instead of urrllib - [ ] started to implement type annotations in the
populate
scripts - [ ] modified
settings.py
to expose allowed hosts and specify the DB name and password mapped in thedocker-compose.yml
file - [ ] Changed the requirements.txt dependency to use the latest version of
psycopg2-binary
compatible with the project and Docker - [ ] Changes to the README to reflect the new install process, as well as some clarifications on how to generate the API key
How to Test the Changes
- Pull this branch (
dockerize
) - Add your API key to the
.prs
file as before - Install Docker Desktop if you don't have it yet
- Run
docker-compose up
to start the install process. Follow other instructions on the README to restart the image. - Go to
http://0.0.0.0:8000/
and click around in the app. It should have the same functionality as described in the book: loading all images, navigating all genres, 'buy' generates a bookmark for a movie, and the analytics module shows logging tracking events.
Hey @kimfalk bump on this. Wanted to make sure you saw it and had a chance to reply with any questions/concerns. Thanks!
I was just about to offer a Dockerize'd PR myself, @veekaybee. Fantastic work! :)
He @veekaybee,
Thank you for your work, I have a dockerized version to push the master branch myself. Similar to the one in the https://github.com/kimfalk/live-project. I will push that one of these days, and then I will go through your PR.
Great, thanks @kimfalk!
Hi @veekaybee,
One of these days was a bit optimistic I guess, but now I have added the docker config. Let me know if you still think something is missing.
That's awesome, @kimfalk. Excited to try it out. 😄