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 i
to installnode_modules
dependencies. - Run
npm run build
to build the project. - Run
npm run start
to start the project. Thenodejs
WebSocket server is automatically started using Concurrently, a terminal concurrent ccommand tool.- Alternatively, you can run
node public/ws-server.js
to 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 containsDockerfile
and all codes.
docker run -p 3000:3000 -p 8976:8976 smart-device-usage-detection
-p 3000:3000
: Map main port3000
to container port3000
, forNext.js
app.-p 8976:8976
: Map main portv
to container port8976
, forWebSocket
server.
After running this command, the container will run:
- the next app at
http://localhost:3000
, and - the websocket at
ws://localhost:8976
.
docker ps
You 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_swirles
You 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 login
Docker 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:latest
docker push <dockerhub_username>/<repository_name>:<tag>
For this project, on user Huang Yanzhen, the command would be:
docker push yanzhenhuang/smart-device-usage-detection:latest
Pull 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>