diff --git a/template/go/Dockerfile b/template/go/Dockerfile index 34781826..9e636ccf 100644 --- a/template/go/Dockerfile +++ b/template/go/Dockerfile @@ -1,9 +1,14 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog -FROM golang:1.13-alpine3.12 as builder +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 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 @@ -27,14 +32,14 @@ RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -n WORKDIR /go/src/handler/function -RUN CGO_ENABLED=${CGO_ENABLED} go test ./... -cover +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go test ./... -cover WORKDIR /go/src/handler -RUN CGO_ENABLED=${CGO_ENABLED} GOOS=linux \ +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} \ go build --ldflags "-s -w" -a -installsuffix cgo -o handler . -FROM alpine:3.12 +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 RUN apk --no-cache add ca-certificates \ && addgroup -S app && adduser -S -g app app \ && mkdir -p /home/app \ diff --git a/template/node/Dockerfile b/template/node/Dockerfile index 909f8d40..dbe6cd41 100644 --- a/template/node/Dockerfile +++ b/template/node/Dockerfile @@ -1,6 +1,5 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog - -FROM node:12.13.0-alpine as ship +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} node:12.13.0-alpine as ship COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog diff --git a/template/node12/Dockerfile b/template/node12/Dockerfile index 8a205557..187c870a 100644 --- a/template/node12/Dockerfile +++ b/template/node12/Dockerfile @@ -1,5 +1,5 @@ -FROM openfaas/of-watchdog:0.7.2 as watchdog -FROM node:12.13.0-alpine as ship +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.7.2 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} node:12.13.0-alpine as ship COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog diff --git a/template/php7/Dockerfile b/template/php7/Dockerfile index 2bd9d621..13fb5f14 100644 --- a/template/php7/Dockerfile +++ b/template/php7/Dockerfile @@ -1,10 +1,10 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog # start with the official Composer image and name it -FROM composer:1.7 AS composer +FROM --platform=${TARGETPLATFORM:-linux/amd64} composer:1.7 AS composer # continue with the official PHP image -FROM php:7.2-alpine +FROM --platform=${TARGETPLATFORM:-linux/amd64} php:7.2-alpine # copy the Composer PHAR from the Composer image into the PHP image COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/template/python/Dockerfile b/template/python/Dockerfile index b3be8680..b95824c3 100644 --- a/template/python/Dockerfile +++ b/template/python/Dockerfile @@ -1,6 +1,6 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog -FROM python:2.7-alpine +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:2.7-alpine # Allows you to add additional packages via build-arg ARG ADDITIONAL_PACKAGE diff --git a/template/python3-debian/Dockerfile b/template/python3-debian/Dockerfile index 8108cd6d..b7498ee7 100644 --- a/template/python3-debian/Dockerfile +++ b/template/python3-debian/Dockerfile @@ -1,5 +1,5 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog -FROM python:3 +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3 # Allows you to add additional packages via build-arg ARG ADDITIONAL_PACKAGE diff --git a/template/python3/Dockerfile b/template/python3/Dockerfile index eee3b79c..89c07cce 100644 --- a/template/python3/Dockerfile +++ b/template/python3/Dockerfile @@ -1,6 +1,6 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog -FROM python:3-alpine +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3-alpine # Allows you to add additional packages via build-arg ARG ADDITIONAL_PACKAGE diff --git a/template/ruby/Dockerfile b/template/ruby/Dockerfile index 603cd863..2917abbb 100644 --- a/template/ruby/Dockerfile +++ b/template/ruby/Dockerfile @@ -1,6 +1,6 @@ -FROM openfaas/classic-watchdog:0.18.18 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/classic-watchdog:0.18.18 as watchdog -FROM ruby:2.7-alpine3.11 +FROM --platform=${TARGETPLATFORM:-linux/amd64} ruby:alpine COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog