🐳 Sharing Code in Docker Builds

Step 1/10 : FROM node:12-alpine AS BUILD

It was sending close to `1GB` of data to the build context. There was a `.dockerignore` file, but it was in `frontend`. Since I moved the build context up one level, I needed to move the `.dockerignore` up as well.

## Dockerfile `COPY`

OK. I updated the `.dockerignore` location:



.dockerignore <-- Moved from frontend/

Everything was pretty much working as expected now, except that I needed to update the Dockerfile to copy from the new paths. I.e.

COPY frontend/package*.json
COPY frontend/.browserslistrc frontend/angular.json frontend/ts*.json ./
COPY frontend/src ./src
COPY frontend/nginx.conf /etc/nginx/nginx.conf

All of the COPY commands needed to include the frontend/ prefix.

Finally, I also needed to copy the api models via:

COPY api/src/models /usr/src/api/src/models

Since I was using the build context of api/ + frontend/, copying the api/ models worked no problem.

Success! 🎉

After updating:

  1. The build context
  2. Dockerfile argument
  3. .dockerignore path
  4. docker COPY paths

and including the api models, I was finally able to get a successful build.

And all this to share some TypeScript interfaces... 😂