Dockerfile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Install the base requirements for the app.
  2. # This stage is to support development.
  3. FROM --platform=$BUILDPLATFORM python:alpine AS base
  4. WORKDIR /app
  5. COPY requirements.txt .
  6. RUN pip install -r requirements.txt
  7. FROM --platform=$BUILDPLATFORM node:18-alpine AS app-base
  8. WORKDIR /app
  9. COPY app/package.json app/yarn.lock ./
  10. COPY app/spec ./spec
  11. COPY app/src ./src
  12. # Run tests to validate app
  13. FROM app-base AS test
  14. RUN yarn install
  15. RUN yarn test
  16. # Clear out the node_modules and create the zip
  17. FROM app-base AS app-zip-creator
  18. COPY --from=test /app/package.json /app/yarn.lock ./
  19. COPY app/spec ./spec
  20. COPY app/src ./src
  21. RUN apk add zip && \
  22. zip -r /app.zip /app
  23. # Dev-ready container - actual files will be mounted in
  24. FROM --platform=$BUILDPLATFORM base AS dev
  25. CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"]
  26. # Do the actual build of the mkdocs site
  27. FROM --platform=$BUILDPLATFORM base AS build
  28. COPY . .
  29. RUN mkdocs build
  30. # Extract the static content from the build
  31. # and use a nginx image to serve the content
  32. FROM --platform=$TARGETPLATFORM nginx:alpine
  33. COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip
  34. COPY --from=build /app/site /usr/share/nginx/html