Skip to content

Commit c7bbd01

Browse files
authored
Merge pull request #341 from docker/speed-up-builds-with-platform-flags
Add platform flags to Dockerfile to speed up builds
2 parents 1f24d45 + c4e9cd0 commit c7bbd01

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v2
9+
- name: Set up Docker Buildx
10+
uses: docker/setup-buildx-action@v2
911
- name: Build
10-
uses: docker/build-push-action@v1
12+
uses: docker/build-push-action@v3
1113
with:
1214
push: false

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Install the base requirements for the app.
22
# This stage is to support development.
3-
FROM python:alpine AS base
3+
FROM --platform=$BUILDPLATFORM python:alpine AS base
44
WORKDIR /app
55
COPY requirements.txt .
66
RUN pip install -r requirements.txt
77

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

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

3131
# Do the actual build of the mkdocs site
32-
FROM base AS build
32+
FROM --platform=$BUILDPLATFORM base AS build
3333
COPY . .
3434
RUN mkdocs build
3535

3636
# Extract the static content from the build
3737
# and use a nginx image to serve the content
38-
FROM nginx:alpine
38+
FROM --platform=$TARGETPLATFORM nginx:alpine
3939
COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip
4040
COPY --from=build /app/site /usr/share/nginx/html

0 commit comments

Comments
 (0)