This repo is for developing a Dockerized sentiment analysis application that I built in this repo. Most directories have a README
file to describe the purpose of the directory and for me to take notes. Most of the code is commented so I can remember how things are working and to note learning lessons from this project. Feel free to copy any of this code for your own projects with an acknowledgement.
- Build a Docker container that serves the sentiment analysis model as the ml_service. This model should only have to be loaded once when the container starts up.
- Build a Docker container that serves the UI through which users can submit a sentence. This service is called the ui_service The UI will then send a request to the model container and show the related sentiment score.
- Use
docker-compose
to bring up both services and link them together.
- From the root of this repo, run
docker-compose build
to build the images for the ml_service and the ui_service. This will take a couple of minutes, especially sincetensorflow
is a large package.- Run
docker images
. You should see images calledsentiment_analysis_ml_service
(for the ml_service) andsentiment_analysis_ui_service
(for the ui_service).
- Run
- Start up the ml_service in the background by running
docker-compose up -d ml_service
.- If you run
docker ps
, you should see a container running with the nameml_service
. - If you go to http://localhost:8000/, you should see the message "ML model service is running!".
- If you run
- Start up the ui_service by running
docker-compose up ui_service
.- You should the logs for starting up the container for the ui_service in your Terminal window.
- In a new Terminal window if you run
docker ps
, you should see a container running with the nameui_service
. - If you go to http://localhost:8001/, you should see the web UI displayed.
- Visit http://localhost:8001/ and type in sentences that you would like to get the sentiment for!
- Clean-up:
- Run
docker rm -f ui_service ml_service
to stop and remove the containers. - Run
docker ps -a
to verify that there are no containers running.
- Run
- Run
docker-compose up
from the root of the repo. This will build images for both services and start them up. The logs for both services will print to your Terminal window. - Go to http://localhost:8001/ to use the application.
- Add a Docker container running a SQL database that stores user queries. Maybe the last 5 queries can be displayed on page showing the sentiment classification for a user's sentence.