-
-
Notifications
You must be signed in to change notification settings - Fork 330
Docker
This guide covers multiple scenarios:
- Run app using Human as a full environment inside container
- Run app using Human as NodeJS worker inside container
- Run Human for web inside container
For details see Docker Docs: Installation Guide
Example: Install Docker using official convenience script:
curl https://get.docker.com | sudo sh
Check Docker status installation:
sudo docker version
sudo docker info
sudo systemctl status containerd docker
Get list of running containers
docker ps
Get logs from a running container
docker logs
containerID
Stop container
docker stop
containerID
Go to shell inside container
docker exec -it
containerID
/bin/bash
- To run
human
inside docker container,
simply dockerize your application as usual - Note that if your app has a dependency on
@vladmandic/human
,
all ofhuman
components will be installed by default and not just the library
(for example, this includes copies of in/models
and sources in/src
) - It is strongly recommended to dockerize prodution mode only apps (
npm install --production
)
to avoid installing all ofhuman
dev dependencies inside the container
To minimize size of a container dont install human
as your app dependency
And avoid importing entire @vladmandic/human
as usual:
// const Human = require('@vladmandic/human').default;
Instead import human
library directly as only library is required inside docker container:
const Human = require('./human-dist/human.node.js').default;
Create Docker recipe myapp.docker
in your human
project folder
- Can use
NodeJS
14 or 16 - Minimal footprint as only
/dist
is actually required - Assumes user has NodeJS app
myapp
with itspackage.json
- Modify workdir path as needed
- Modify entry point as needed
FROM node:16
WORKDIR <path-to-myapp>
COPY package.json .
copy <myapp> .
RUN npm install
COPY node_modules/@vladmandic/human/dist ./human-dist
ENTRYPOINT node myapp/index.js
USER node
sudo docker build . --file myapp.docker --tag myapp
- Maps
models
from host to a docker container so there is no need to copy it into each container - Modify path as needed
docker run -docker run -it --init --detach
--volume node_modules/@vladmandic/human/models:$PWD/models
myapp
Create Docker recipe human-web.docker
in your human
project folder
- Can use
NodeJS
14 or 16 - Default package is empty as
human
has no external dependencies - Minimal footprint as only
/dist
is actually required - As an example, copies default
/demo
web app to serve - Uses
@vladmandic/build
as web server - Modify workdir path as needed
FROM node:16
WORKDIR <path-to-myapp>
RUN npm init --yes
COPY build.json .
RUN npm install @vladmandic/build --no-fund
COPY dist ./dist
COPY demo ./demo
EXPOSE 10031
ENTRYPOINT node node_modules/@vladmandic/build/dist/build.js --profile serve
USER node
sudo docker build . --file human-web.docker --tag human-web
- Maps
models
from host to a docker container so there is no need to copy it into each container - Maps human internal web server to external port 8001 so app can be accessed externally
docker run -docker run -it --init --detach --name human-web-instance
--publish 8001:10031
--volume node_modules/@vladmandic/human/models:$PWD/models
human-web
Human Library Wiki Pages
3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition