diff --git a/4 b/4 new file mode 100644 index 00000000..85d302b5 --- /dev/null +++ b/4 @@ -0,0 +1,42 @@ +# Install the base requirements for the app. +# This stage is to support development. +FROM python:3.12-alpine AS base +WORKDIR /app +COPY requirements.txt . +RUN pip install -r requirements.txt + +FROM node:20-alpine AS app-base +WORKDIR /app +COPY app/package.json app/yarn.lock ./ +COPY app/spec ./spec +COPY app/src ./src + +# Run tests to validate app +FROM app-base AS test +COPY .yarnrc.yml . +RUN yarn install --immutable +RUN yarn test + +# Clear out the node_modules and create the zip +FROM app-base AS app-zip-creator +COPY --from=test /app/package.json /app/yarn.lock ./ +COPY app/spec ./spec +COPY app/src ./src +RUN apk add zip && \ + zip -r /app.zip /app + +# Dev-ready container - actual files will be mounted in +FROM base AS dev +CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"] + +# Do the actual build of the mkdocs site +FROM base AS build +COPY . . +RUN mkdocs build + +# Extract the static content from the build +# and use a nginx image to serve the content +FROM nginx:alpine +COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip +COPY --from=build /app/site /usr/share/nginx/html + diff --git a/Dockerfile b/Dockerfile index 5b9ee4de..85d302b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ # Install the base requirements for the app. # This stage is to support development. -FROM --platform=$BUILDPLATFORM python:alpine AS base +FROM python:3.12-alpine AS base WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt -FROM --platform=$BUILDPLATFORM node:18-alpine AS app-base +FROM node:20-alpine AS app-base WORKDIR /app COPY app/package.json app/yarn.lock ./ COPY app/spec ./spec @@ -26,16 +26,17 @@ RUN apk add zip && \ zip -r /app.zip /app # Dev-ready container - actual files will be mounted in -FROM --platform=$BUILDPLATFORM base AS dev +FROM base AS dev CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"] # Do the actual build of the mkdocs site -FROM --platform=$BUILDPLATFORM base AS build +FROM base AS build COPY . . RUN mkdocs build # Extract the static content from the build # and use a nginx image to serve the content -FROM --platform=$TARGETPLATFORM nginx:alpine +FROM nginx:alpine COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip COPY --from=build /app/site /usr/share/nginx/html + diff --git a/README.md b/README.md index 5ccd135d..883dfdc5 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,6 @@ If you find typos or other issues with the tutorial, feel free to create a PR an If you have ideas on how to make the tutorial better or want to suggest adding new content, please open an issue first before working on your idea. While we love input, we want to keep the tutorial scoped to new-comers. As such, we may reject ideas for more advanced requests and don't want you to lose any work you might -have done. So, ask first and we'll gladly hear your thoughts! +have done. So, ask first and we'll gladly hear your thoughts! + +hii!