Skip to content

Dockerizing the demo app

  Less than to read

In this last step, you will lear how to package the demo app as a docker container. You need a Dockerfile to define the Docker container:

  # To build use docker build -t . in the current directory

  FROM node:12-stretch

  USER root


  RUN apt-get -y update
  RUN DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

  #dumb-init entrypoint
  ADD /usr/local/bin/dumb-init
  RUN chmod +x /usr/local/bin/dumb-init

  COPY nodejs/package.json /nodejs/package.json
  COPY /

  RUN chmod +x /

  WORKDIR /nodejs
  RUN node -v
  RUN npm -v
  RUN npm install

  COPY nodejs /nodejs


  RUN ls

  ENTRYPOINT  ["/usr/local/bin/dumb-init" , "--", "/"]

And a as the entrypoint of that Docker container.


cd /nodejs
npm start

These 2 files are placed at the same level of nodejs folder and need to be saved under UNIX format (with LF ending character). Now you will build your docker container:

  docker build -t demo-app:latest .

Then start the container with the right parameter on:

  • “ENDPOINT_URL”: API Gateway of the sandbox environment

  • “CLIENT_ID”: your App ID

  • “CLIENT_SECRET”: your App secret

docker run -p 5050:5050 -e ENV_URL='https://localhost:5050' -e COLOR='Demo App' -e APPLICATION='green' -e ENDPOINT_URL='ENDPOINT_URL' -e CLIENT_ID='CLIENT_ID' -e CLIENT_SECRET='CLIENT_SECRET' demo-app:latest

Now you have a docker container deployed at https://localhost:5050 with the same functionality as your VSCode launched version.

You can also download the VSCode project at the end of this step here.