Alias: You Focus Your Walk
-
Group Members: Huang Yanzhen DC126732, Mai Jiajun DC127853
-
Supervisor: Prof. Bob Zhang
This is the frontend of the project
Smart Device Usage Detection, i.e.YOU FOCUS YOUR WALK. This repository contains the NextJS + React webpage with a simple Node server for WebSocket communication.To support the throughput of WebSocket, the frontend is run LOCALLY where the inference backend run. It does not run on the server of storage backend that stores faces.
To build with npm, make sure you have Node Environment installed. Make sure to add npm script to your environment variable (windows, zsh, bash, etc.).
- Run
npm ito installnode_modulesdependencies. - Run
npm run buildto build the project. - Run
npm run startto start the project. ThenodejsWebSocket server is automatically started using Concurrently, a terminal concurrent ccommand tool.- Alternatively, you can run
node public/ws-server.jsto only start the WebSocket server.
- Alternatively, you can run
You can also build this project with docker.
docker build -t smart-device-usage-detection .-t smart-device-usage-detection: Name the Docker image assmart-device-usage-detection..: Build context is current directory, which containsDockerfileand all codes.
docker run -p 3000:3000 -p 8976:8976 smart-device-usage-detection-p 3000:3000: Map main port3000to container port3000, forNext.jsapp.-p 8976:8976: Map main portvto container port8976, forWebSocketserver.
After running this command, the container will run:
- the next app at
http://localhost:3000, and - the websocket at
ws://localhost:8976.
docker psYou will receive:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d4238047209a smart-device-usage-detection "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:3000->3000/tcp, 0.0.00:8080->8080/tcp eloquent_swirlesYou will be mainly using the CONTAINER ID.
Using the CONTAINER ID get from docker ps, run
docker stop <CONTAINER_ID>Using the CONTAINER ID get from docker ps, run
docker rm <CONTGAINER_ID>docker loginDocker images need to be tagged properly to match the naming conventions of Docker Hub.
docker tag <local_image_name>:<tag> <dockerhub_username>/<repository_name>:<tag>For this project, on user Huang Yanzhen, the command would be:
docker tag smart-device-usage-detection:latest yanzhenhuang/smart-device-usage-detection:latestdocker push <dockerhub_username>/<repository_name>:<tag>For this project, on user Huang Yanzhen, the command would be:
docker push yanzhenhuang/smart-device-usage-detection:latestPull the image from Docker Hub on your mirror server.
docker pull <dockerhub_username>/<repository_name>:<tag>docker tag <local_image_name>:<tag> <dockerhub_username>/<repository_name>:<tag>docker push <dockerhub_username>/<repository_name>:<tag>