Skip to content

Instantly share code, notes, and snippets.

@manrajgrover
Last active January 29, 2024 12:56
Show Gist options
  • Save manrajgrover/84f73a295f85e5902a9239fa698b7603 to your computer and use it in GitHub Desktop.
Save manrajgrover/84f73a295f85e5902a9239fa698b7603 to your computer and use it in GitHub Desktop.
Quick Docker Environment for TensorFlowJS Node
root=/path/to/root
project=/path/to/project

Quick Docker environment for TensorFlowJS Node

Personal docker environment for TensorFlowJS Node for Development purpose

Why?

Because:

  1. I didn't want to install Xcode (which also takes up a lot of space)
  2. Easy to setup on different machines

How to use this?

Assuming you have Docker setup completed:

If you plan to make use of compose file shared here:

  1. Create a .env file from .env.sample and specify root and project volumes.

And then:

  1. Run $ docker-compose build command to build the image
  2. Run $ docker-compose run tensorflowjs command to run the container.

Otherwise:

  1. Run $ docker build . command to build the image
  2. Run $ docker run -it --rm <imageid> command to run the container.

Why is this not on DockerHub?

I haven't given it much thought

version: '3'
services:
tensorflowjs:
build:
context: .
dockerfile: Dockerfile
image: tfjs-node:cpu
env_file:
- .env
volumes:
- "${root}:/root"
- "${project}:/root/project"
command: /bin/bash
FROM ubuntu:16.04
LABEL maintainer="Manraj Singh Grover <[email protected]>"
# Install basic CLI tools etc.
RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends \
build-essential \
curl \
git-core \
iputils-ping \
pkg-config \
rsync \
software-properties-common \
unzip \
wget
# Install NodeJS
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install --yes nodejs
# Install yarn
RUN npm install -g yarn
# Install tfjs-node
RUN yarn add @tensorflow/tfjs
RUN yarn add @tensorflow/tfjs-node
# Clean up commands
RUN apt-get autoremove -y && apt-get clean && \
rm -rf /usr/local/src/*
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR "/root/project"
CMD ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment