This example shows how to run office 365 addins as microservices on Docker containers
###watch this video to see this in action
Below sections would be covered in this sample
- Why Docker?
- Prerequisites
- Configure Docker
- Docker Components
- Docker Commands
- Build NodeJS Base Image
- Build Office 365 NodeJS Microservice
- Dockerize Office365 Microservice
- Publish Microservice to Azure Docker Container
- How to run this sample
- Docker is an exciting new technology to build platform agnostic light weight apps/micro services/containers which can be provisioned, deployed, scaled faster than traditional VM's.
- Building Cloud hosted/provider hosted SharePoint/Office365 addins requires additional infrastructure to the mix.
- Docker's X-Plat CLI tools to provide continous integration and delivery thus making DevOps relatively simpler. For more details read docker docs
- Windows 7 or Above
- Office 365 subscription
- Azure subscription
- Visual Studio Code
- Install docker tool kit from docker docs
- Run docker quick start terminal
- To run this sample straightaway skip to "10. How to run this sample" section
- Docker Images > Blueprints of our application
- Docker Container > Created from docker images and are real instances of our application
- Docker Daemon > Building, running and distributing Docker containers
- Docker Client > Run on our local machine and connect to the daemon
- Docker Hub > A registry of docker images
- $docker build
- $docker run
- $docker search
- $docker ps
- $docker images
- $docker rmi
- $docker pull
- $docker push
- $docker-machine env
- $docker-machine create
- $docker attach
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y nodejs nodejs-legacy npm
RUN apt-get clean
Run the sample Office 365 Add in from your local machine following this article
- First install the required packages from package.json
COPY ./package.json src/
RUN cd src && npm install
- Then copy all the source code
COPY . /src
- Set working directory for docker daemon
WORKDIR src/
- Set default comment on start
CMD ["npm","start"]
- Now build the Docker Image and Run it
docker build -t o365addin-docker:0.1 .
docker run -d -p 80:3000 o365addin-docker:0.1
-
Change the AppID and Redirection URL's in Azure and authHelper.js
-
Test the app in browser
- Create SSL certs using Open SSL
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout o365-docker.pem -out o365-docker.pem
openssl x509 -inform pem -in o365-docker.pem -outform der -out o365-docker.cer
openssl pkcs12 -export -out o365-docker.pfx -in o365-docker.pem -name "o365-docker Certificate"
-
Upload o365-docker.pem to Azure -> Settings -> Management Certificates -> Upload
-
Now Create a docker Microservice in Azure
docker-machine create -d azure --azure-subscription-id="d48ccdca-d4ab-4579-89fa-ed113033bf74" --azure-subscription-cert="o365-docker.pem" --azure-location="East US" o365ondocker
- Connect to Azure Docker machine
eval "$(C:/Program\ Files/Docker\ Toolbox/docker-machine.exe env o365ondocker)"
-
Change the AppID and Redirection URL's in Azure and authHelper.js
-
Build and Run the app
docker build -t o365addin-docker:0.1 .
docker run -d -p 80:3000 o365addin-docker:0.1
- Test the app in browser
- Open Docker quick start terminal
- Clone this repo
git clone https://github.com/spbreed/O365OnDocker.git
- Update Office 365 App permissions and authhelper.js with Docker IP
docker-machine ip default
- Build the docker image
docker build -t o365addin-docker:0.1 .
- Run the docker container
docker run -d -p 80:3000 o365addin-docker:0.1