0

in order to test my Excel add-in in a "realistic environment" I am trying to deploy my add-in in a Docker container, however it seems Excel can't reach my add-in running in Docker. I am pretty sure this has something to do with HTTPS, since I am able to access my extension from a browser (only with HTTP though). I initially created my add-in using the Yeoman generator and the React taskpane template, just to be clear.

Here is my Dockerfile:

FROM node:14.2.0-alpine3.10 as build
RUN echo "*** Build Phase ***"
WORKDIR .
ENV PATH ./node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci
COPY . ./
RUN npm run build

FROM nginx:stable-alpine
RUN echo "*** Deployment Phase ***"
COPY --from=build ./dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

The first part builds my add-in for production in a clean node environment (npm run build uses webpack to minimize and compile my code in a ./dist folder). The second part of the Dockerfile just creates a simple nginx server for hosting my production ready add-in from the dist folder.

After building my Docker image with this file, I run it with docker run -it --rm -p 3000:80 addin:1 to start the nginx server running in Docker.

During development, the npm run start and npm run dev-server commands generate SSL certificates for my addin thanks to the office-addin-dev-certs package and it just works "out of the box".

What should I change in my Dockerfile/nginx to get my add-in served via HTTPS ? And how should I create my SSL certficates ?

  • Try following an article like https://www.johnmackenzie.co.uk/post/creating-self-signed-ssl-certificates-for-docker-and-nginx/ and see if you can solve your issue – Tarun Lalwani May 13 '20 at 15:21
  • @TarunLalwani Thank you for that link! I've now managed to get HTTPS working in my browser and the addin doesn't give me an error in Excel, but it shows me a blank window (in Excel). In the browser console, I get Error: "Invariant failed" related to React but it is indecipherable and my React code was working fine when I developped it. – iHaveCodingIssues May 14 '20 at 13:09
  • Did you get it to locally work inside the excel add-in earlier? – Tarun Lalwani May 14 '20 at 16:02
  • @TarunLalwani Yes, I did by using the included `npm run start` command. – iHaveCodingIssues May 15 '20 at 15:38
  • There are some threads on that too, see if those helps. Like this one https://stackoverflow.com/questions/55552147/invariant-failed-you-should-not-use-route-outside-a-router – Tarun Lalwani May 15 '20 at 15:43

0 Answers0