Skip to content

Commit

Permalink
Move TARGET/BUILD PLATFORM higher in Dockerfiles
Browse files Browse the repository at this point in the history
This is a partial fix for #232 where "docker build" could not
override the two variables for multi-arch builds and caused a
user error for building on an arm device.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Dec 2, 2020
1 parent 05a3ea5 commit 31d5210
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
10 changes: 5 additions & 5 deletions template/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13-alpine3.12 as builder

# Required to enable Go modules
RUN apk add --no-cache git

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

# Allows you to add additional packages via build-arg
ARG ADDITIONAL_PACKAGE
ARG CGO_ENABLED=0
Expand Down
3 changes: 3 additions & 0 deletions template/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:12-alpine as ship

Expand Down
3 changes: 3 additions & 0 deletions template/node12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.7.2 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:12-alpine as ship

Expand Down
3 changes: 3 additions & 0 deletions template/php7/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog

# start with the official Composer image and name it
Expand Down
4 changes: 3 additions & 1 deletion template/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:2.7-alpine

# Allows you to add additional packages via build-arg
Expand Down
3 changes: 3 additions & 0 deletions template/python3-debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3

Expand Down
4 changes: 3 additions & 1 deletion template/python3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3-alpine

# Allows you to add additional packages via build-arg
Expand Down
4 changes: 3 additions & 1 deletion template/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
ARG TARGETPLATFORM
ARG BUILDPLATFORM

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.4 as watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} ruby:alpine

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
Expand Down

0 comments on commit 31d5210

Please sign in to comment.