Build and Run the Smart City Sample on Public Cloud or Local Machine
AWS EC2 INSTANCE, AMAZON LINUX 2
AZURE VM INSTANCE, UBUNTU 16.04 LTS
GOOGLE CLOUD PLATFORM VM INSTANCE, UBUNTU 16.04 LTS
Unless specifically specified, all the commands in the tutorial apply to all the 3 cloud services.
For AWS, run the following commands to install the software packages required to build the sample:
$ sudo yum update –y $ sudo amazon-linux-extras install –y docker $ sudo service docker start $ sudo yum install –y cmake git
$ sudo apt-get install –y cmake git
$ sudo docker swarm init Swarm initialized: current node (04k9ydxpdtx40nym8ag2j499r) is now a manager.
docker swarm join --token SWMTKN-1-2jthey7uay7ym5ko1db4etp9lt5sjmi8u4qhkv4owe1ysip943-5novs363q4nby8kgaek8ury6i 172.31.18.164:2377 $
2. Clone the Sample Source Code
Run the following command to clone the Smart City Sample source code:
$ git clone https://github.com/OpenVisualCloud/Smart-City-Sample
3. Build the Sample
$ cd Smart-City-Sample $ mkdir build $ cd build $ cmake .. This script will build third party components licensed under various open source licenses into your container images. The terms under which those components may be used and distributed can be found with the license document that is provided with those components. Please familiarize yourself with those terms to ensure your distribution of those components complies with the terms of those licenses. -- Configuring done -- Generating done -- Build files have been written to: /home/ec2-user/smart-city-aws/Smart-City-Sample/build $ make ... Successfully built ee416bcdd384 Successfully tagged smtc_web:latest Built target build_smtc_web
4. Start the Sample Service
Now, it is time to start the sample service:
$ make start_docker_swarm Total reclaimed space: 0B Total reclaimed space: 0B bash into new container...smtc_certificate Generating a 4096 bit RSA private key ... Ignoring unsupported options: restart, ulimits Creating network smtc_default Creating secret smtc_self_key Creating secret smtc_self_crt Creating secret smtc_dhparam_pem Creating service smtc_health_check Creating service smtc_where_indexing_local Creating service smtc_video_analytics Creating service smtc_mqtt Creating service smtc_database Creating service smtc_web Creating service smtc_storage_cleanup_local Creating service smtc_onvif-discovery Built target start_docker_swarm $
5. Test the Sample
The Smart City Sample exposes a web interface at port 443. We need to create a SSH tunnel to access it, as follows:
$ ssh -L 8443:localhost:443 -Nf -i "keypair.pem" email@example.com
For Azure or GCP
For Azure or GCP, the command is almost the same.
$ ssh -L 8443:localhost:443 -Nf -i ssh_private_key user_name@instance_public_ip