Deployment in Docker - RaceDetectionService/RaceDetectionService_Server GitHub Wiki
-
OS: Ubuntu 18.04
-
Install docker
sudo apt update
sudo apt install docker.io
Or check the following guide. https://docs.docker.com/install/linux/docker-ce/ubuntu/
All the docker images ready for use are uploaded to DockerHub. https://hub.docker.com/repository/docker/ouankou/rds The images contain all tools with proper configuration. Because Flask code could be updated frequently, they are not included in the docker image. Instead, they should be mounted into the docker container.
sudo docker pull ouankou/rds:metaservice
sudo docker pull ouankou/rds:threadsanitizer
sudo docker pull ouankou/rds:archer
sudo docker pull ouankou/rds:inspector
ThreadSanitier is taken as an example to show how to use the docker image.
Follow the official guide or other instructions.
https://clang.llvm.org/docs/ThreadSanitizer.html
Flask framework under python3 has been installed in the docker image. For now, we could manually mount or download the source code of Flask server into the container and run it. Please make sure the Flask server is running correctly on the local machine. If it doesn't work individually, it won't work inside the docker as well.
To deploy the Flask server, we also need to map the host port to the docker container port. For example, assume we have an available Flask server running on the port 5000 in the container. The port 5001 on the host is assigned to the microservice. While creating the container, the port mapping is needed as follows.
# assume Flask source code is located in $HOME/flask
sudo docker run -it -p 5001:5000 --name rds_tsan -v $HOME/flask:/opt/flask ouankou/rds:threadsanitizer bash
So far, we only have a dummy Flask server, which can't work as expected yet (API calls, passing files, JSON, etc). To use this dummy Flask server, mount src/metaservices/flask
into the container.
Then inside the containe, start the Flask server.
cd /opt/flask
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# export FLASK_APP=Flask_TSan.py
# use dummy server instead
export FLASK_APP=terminal.py
flask run --host=0.0.0.0
Finally, on the host browser, we can access the microservice at 127.0.0.1:5001
. For other external machines, it can be accessed at <host_ip>:5001
.
sudo docker start rds_tsan
sudo docker restart rds_tsan
sudo docker stop rds_tsan
sudo docker rm rds_tsan
After creating a container, run the following command to enter it for debugging or something else.
sudo docker exec -it rds_tsan bash