Polysent is an online poll maker that allows you to instantly obtain anonymously-submitted results with ease. In addition, you can browse and participate in other polls that people have submitted. The types of polls that you'll find here are relative to a myriad of topics such as: politics, entertainment, technology, etc.
Contact email: polysentdotcom@gmail.com
- Startup Mongo database:
$ mongod
- Start the app (in a new tab or window):
$ nodemon
- Start gulp (in a new tab or window):
$ gulp [dev|build]
The web application is served from within a Docker container on a Digital Ocean VPS droplet running Ubuntu 18.04.
To build an image for Polysent, type the following command from within the root directory:
$ docker build -t matthewkosloski/polysent .
Push the image to DockerHub:
$ docker push matthewkosloski/polysent
$ ssh matt@polysent.com
$ sudo docker pull matthewkosloski/polysent
You can optionally delete the older images of Polysent with the prune
command:
$ sudo docker system prune
Create a new container for the Polysent web app.
Explanation of the command:
--network="host"
: Allows us to connect to the Mongo database running on the host (the VPS server). Now,localhost
in the app refers to the host (e.g., 'mongodb://localhost:27017/polysent').--name=polysent_container
: By default, Docker generates a random name for the container. This provides the container with the name ofpolysent_container
. This is helpful when we want to stop the container.--rm
: This means that when we stop the container usingsudo docker stop polysent_container
, the container will automatically be deleted. To confirm this, simply runsudo docker ps -a
.-d
: This means that we want the container to run in the background. In other words, we do not want to be inside of the shell of the container after we run it.matthewkosloski/polysent
: This is the name of the image.
$ sudo docker run --network="host" --name=polysent_container --rm -d matthewkosloski/polysent
When there is an updated image for Polysent, we would like to create a new container with it.
Use the following command to stop the old container (This assumes the name of the old container is polysent_container
):
$ sudo docker stop polysent_container
If the old container was ran using the --rm
flag, it should have been deleted after running the above command. To confirm, simply run:
$ sudo docker ps -a
Download the latest version of the Polysent image from DockerHub:
$ sudo pull matthewkosloski/polysent
$ sudo docker run --network="host" --name=polysent_container --rm -d matthewkosloski/polysent
If we need to create a new droplet for Polysent, follow the below steps to set up a new droplet.
We first want to create a droplet running Ubuntu. Log in to Digital Ocean and create a new droplet, preferable the lowest tier running from New York. Make sure to include your computer's SSH key to the droplet.
Follow the steps in this blog post to perform initial server setup. This includes created a non-root sudo user and setting up the ufw
firewall.
Follow the beginning part of this blog post to install Docker on Ubuntu.
Follow the steps in this blog post to install MongoDB.
$ sudo docker pull matthewkosloski/polysent
Follow the above steps to start a container.
We can use the mongoexport
command to export the contents of the polls
collection, which is part of the polysent
database:
$ mongoexport --db polysent --collection polls --out polls_2020_04_20_1820.json
The filename convention we are using is collection_YYYY_MM_DD_HHMM.json
where HHMM
is time on the 24-hour clock.
We can use the mongoimport
command to import the contents of a json file to populate the polls
collection, which is part of the polysent
database:
$ mongoimport --db polysent --collection polls --file polls_2020_04_20_1820.json