Files
OpenFace/docker-compose.yml
Mike McDermott b802889ef0 - Use staged container builds to improve caching and reduce size (#727)
* - Use staged container builds to improve caching and reduce size
- Image size reduced from 8 GB to 1.6ish
- Switched from Make to Ninja for faster builds that do not hog processor
- Removed unneded dependencies
- Added to .dockerignore
- Readme for docker stuff

- Staged Builds
    - Docker's overlay FS means that `rm`ing files does not reduce size
    - Once build artifacts are build, the build dependencies are no longer needed
    - Both of these can be solved by building in a temporary image and copying
    only the needed libraries in
    - Leverages DESTDIR to generate a directory structure that can be just
    copied onto the `/` of the filesystem
    - Similarly, the data files (like models) can be downloaded ahead of time
    into their own image and copied in. This saves on network IO.
    - Anything in a RUN directive that is non-deterministic (e.g. downloading
    a file from a link, the content of that link changes) does not cause a cache
    miss, so if you need to update something RUN uses, either modify the
    dockerfile or build with `--no-cache` to force a rebuild
- Switch to Ninja
    - cmake can generate many types of build systems
    - Ninja builds faster than GNU Make
    - `make -j` has a tendency to lock up my system when building locally
    - Do not need to tell ninja how many jobs to run
- .dockerignore
    - Paths in .dockerignore are basically invisible to dockerd, so when dockerd
    zips up the build context, all of the cruft can be ignored
    - it is beneficial to docker build speed to add any large, unnecssary files
    and directories to .dockerignore.
    - Just remember they cannot be seen by dockerd

* removing cruft and some format fixes

* updated dockerfile to opencv 4.1.0
2019-07-04 08:13:48 +01:00

25 lines
758 B
YAML

---
# Variables can be set from the shell: `DOCKERTAG=foo docker-compose build`
# or from a .env file. See docker-compose documentation for details
# Variable DOCKERUSER should be set to your dockerhub user
# Alternatively, use a docker registry url as the image name
version: '3.7'
services:
## Image runtime service
## This can be used to add volume mounts or pass environment variables
## Todo: make a service which can use the container interactively
openface:
container_name: openface
build:
context: .
dockerfile: docker/Dockerfile
image: "${DOCKERUSER}/openface:${DOCKERTAG}"
tty: true
volumes:
- "${DATA_MOUNT}:${DATA_MOUNT}"
environment:
DATA_MOUNT: "${DATA_MOUNT}"
command: ["bash"]
...