Skip to content

Commit

Permalink
Merge pull request #341 from docker/speed-up-builds-with-platform-flags
Browse files Browse the repository at this point in the history
Add platform flags to Dockerfile to speed up builds
  • Loading branch information
mikesir87 authored Jan 9, 2023
2 parents 1f24d45 + c4e9cd0 commit c7bbd01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v1
uses: docker/build-push-action@v3
with:
push: false
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Install the base requirements for the app.
# This stage is to support development.
FROM python:alpine AS base
FROM --platform=$BUILDPLATFORM python:alpine AS base
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

FROM node:18-alpine AS app-base
FROM --platform=$BUILDPLATFORM node:18-alpine AS app-base
WORKDIR /app
COPY app/package.json app/yarn.lock ./
COPY app/spec ./spec
Expand All @@ -25,16 +25,16 @@ RUN apk add zip && \
zip -r /app.zip /app

# Dev-ready container - actual files will be mounted in
FROM base AS dev
FROM --platform=$BUILDPLATFORM base AS dev
CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"]

# Do the actual build of the mkdocs site
FROM base AS build
FROM --platform=$BUILDPLATFORM 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
FROM --platform=$TARGETPLATFORM 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

0 comments on commit c7bbd01

Please sign in to comment.