This project is a recreation of a web counter used as an in-class example for running an HTTP server, recreated with Node.js, displaying the counter as HTML code, through an DOM implementation for Node, JSDOM, running in a Docker container, getting, and incrementing the count through a Docker Volume, within a remote server (AWS EC2).
Sorry this increments by 2, implementing this took forever...
Make sure that Node.js and npm are both installed on your system through your package manager.
Make sure that Git and Docker are installed.
Amazon Linux has Docker in its repos, Docker can be installed on Ubuntu through the Snap Store
sudo yum in git docker -yEnable and start the Docker systemd service.
sudo systemctl enable --now docker.servicesudo apt install git
sudo snap install dockerConnect the docker:home plug to the Core snap:
sudo snap connect docker:homeMake sure that the instance has HTTP access in Network Settings (port 80), so that way a web browser can access it.

Take the contents of userdata.sh, and put in into the "User Data" option in "Advanced Settings" upon the creation of an EC2 instance.
This script should install git and Docker for you, and enable Docker's systemd service.
Do the same, except take the contents out of ubuntuuserdata.sh instead.
Clone this repository:
git clone https://github.com/cs220s23/david-node-counter && cd david-node-counterInstall npm modules:
npm installRun as superuser (to expose port 80):
sudo node app.jsAccess the counter on a web browser by typing localhost:80.
Terminate the server by running Ctrl-X in the terminal, or kill the process.
Build this repository in a new Docker image, tagged counter (omit sudo on all commands if running Docker on macOS)
sudo docker build -t counter .Then, run the container (assuming it has the tag counter), with port 80, in detached mode, giving the container the name counter, mounting the folder data (in this repo) on /app/data in the container for persistence.
sudo docker run -d -p 80:80 -v $(pwd)/data:/app/data --name counter counterAccess the program on a web browser on localhost:80 if running Docker locally, or on the public IPv4 DNS, on port 80 if using a server like EC2.
Stop the container (with the name counter) by running:
sudo docker rm -f counterDelete the data folder to reset the number on the counter.
rm -r dataUse sudo if you are using Docker on Linux, since Docker runs as root, data is only mutable by root.
sudo rm -r dataAlternatively, if typing (or copy-pasting) numerous commands is too cumbersome, if Docker is already installed in the instance, run the up and down files to build and run the Docker container of the program, and to terminate it respectively.
Make sure both the up and down scripts have executable permissions
chmod +x up downRun the script (replace with down to remove the containers)
sudo ./up