0. Introduction
Rencently I am learning to use Docker which is very helpful to isolate apps to keep the OS clean. So I searched for interesting applications of Docker. Then I found the Pokemon Go Map from Github. This article is to take notes on the installation process of pokemon go map with docker on Ubuntu 14.
1. Installing Docker on Ubuntu 14.04
The installation of docker follows with the instruction of Docker's doc:
$ uname -r #checking kernel version
3.11.0-15-generic
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
$ sudo vim /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-trusty main #create this file and insert this line
$ sudo apt-get update
$ sudo apt-get purge lxc-docker #purge previous version of docker (if any)
$ apt-cache policy docker-engine #confirm it will pulling the docker from the right source
docker-engine:
Installed: 1.12.0-0~trusty
Candidate: 1.12.0-0~trusty
Version table:
*** 1.12.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
100 /var/lib/dpkg/status
1.11.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
...
$ sudo apt-get install linux-image-extra-$(uname -r) #Ubuntu14, 15 and 16 would need this, but it should be pre-installed
$ sudo apt-get install apparmor #Ubuntu12 and 14 would need this, but it should be pre-installed
#Start instlalling Docker
$ sudo apt-get install docker-engine
$ sudo service docker start
$ sudo docker run hello-world #This is a test run to make sure the docker work. It will pull an image name "hello-world" and run the container showing welcome message.
2. Deploy Pogomap on Docker
The installation of Pogomap refers to:
To make it simple, here is what you need to prepare before the installation:
- You need an account of Pokemon Trainer Club (PTC), which can be applied from here. The newly applied account can be used in 15 min after activation.
- Google Maps Key, see this.
- Default coordinates, can be found on Google Maps by simply clicking on any place you're interested.
When all ready, run the following command as root:
$ docker run -d -p xxxx:5000 --name pogomap \ #xxxx is the port on the host, while 5000 is the port in the container
sych74/pokemongo-map \ #Sometimes you can't find this image, but there's other similar one on the Docker Hub
-a ptc -u username_of_PTC -p password_of_PTC \
-k 'google-maps-key' \
-l 'default coordinates' \
-st 5 #It's better to use 10, because my ip is blocked after a week later when I used 5.
#The pogomap image should be pulled back and running right now. If you want to check the status:
$ docker logs -f pogomap #When you found the message looks like the following, it mean the server is properly running. Otherwise, you will need to check if your PTC account or Google-maps-key.
2016-08-10 08:32:16,506 [ search_worker_0][ search][ INFO] Search step 3 beginning (queue size is 58)
2016-08-10 08:32:17,512 [ search_worker_0][ models][ INFO] Upserted 0 pokemon, 504 pokestops, and 16 gyms
# If need to use the bash in the container:
$ docker exec -ti pogomap bash
3. Configure Nginx as reverse proxy to point a sub-domain to Pogomap
Edit or create the configuration file of the sub-domain site under /etc/nginx/sites-available/
:
server {
listen 80;
server_name sub.domain.com;
location / {
proxy_pass http://localhost:xxxx;
}
}
If the sub.domain.com is newly created, then make a link to enable the new sub.domain.com:
$ ln -s /etc/nginx/sites-available/sub.domain.com /etc/nginx/sites-enabled/sub.domain.com
$ service nginx restart
PS: The Pogomap wiki says SSL is needed when using location services. However, if you are using Cloudflare just like me, then you have the free SSL already. There is no need to listen to 443 in the Nginx, but you need to set the website to force using HTTPS in the Cloudflare.