From 863537675d11485138d6d0a4d42ec5ca2ee13d5f Mon Sep 17 00:00:00 2001 From: Karthik Muralidharan Date: Wed, 28 Jun 2017 14:05:35 +0530 Subject: [PATCH] add; Dockerfile for running inside a container and update README --- Dockerfile | 19 +++++++++++++++++++ README.md | 26 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..46ddb61e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:alpine + +# Default port is set to 3000. +# This will be overriden if a diffferent value is provided as an argument for the container. +ENV PORT 3000 + +RUN apk update +RUN apk upgrade +RUN apk add git bash curl wget +RUN rm -rf /var/cache/apk/* + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY package.json /usr/src/app/ +RUN npm install && npm cache clean --force +COPY . /usr/src/app + +CMD [ "npm", "start" ] diff --git a/README.md b/README.md index f2489b06..bcab8de3 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,13 @@ all the config values we need to run the application: ## A Note on API Keys When you generate an API key pair at the URLs above, your API Secret will only -be shown once - make sure to save this in a secure location, +be shown once - make sure to save this in a secure location, or possibly your `~/.bash_profile`. ## Setting Up The Application Create a configuration file for your application: + ```bash cp .env.template .env ``` @@ -27,11 +28,13 @@ cp .env.template .env Edit `.env` with the configuration parameters we gathered from above. Next, we need to install our dependencies from npm: + ```bash npm install ``` Now we should be all set! Run the application: + ```bash npm start ``` @@ -43,6 +46,27 @@ video in both the tabs! ![screenshot of chat app](https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/video2.original.png) +## Using Docker + +You need to build a docker image with the dependecies installed. + +``` bash +docker build -t video-quickstart-js . +``` + +Once the image is created, you can run the container by running the `docker run` command. Replace the +variables `$HOST_PORT`, `$PORT`. + +``` bash + docker run -it --rm \ + -p $HOST_PORT:$PORT \ + --env-file .env \ + video-quickstart-js:latest +``` + +Add `-d` as an option for running in daemon mode. +Add `--restart always` options for restarting the container incase of failure or system restart. + ## Examples The project contains some common use-case examples for the Twilio Video JS SDK.