From e490943c8d6c425247af1b07f8c2dfef4ae13f71 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 24 Jan 2023 17:23:33 +0000 Subject: [PATCH] Update to Go 1.19 and Alpine 3.17 Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/golang-http/Dockerfile | 9 +++++---- template/golang-http/template.yml | 2 +- template/golang-middleware/Dockerfile | 7 ++++--- template/golang-middleware/template.yml | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/template/golang-http/Dockerfile b/template/golang-http/Dockerfile index 121c303..d1160a4 100644 --- a/template/golang-http/Dockerfile +++ b/template/golang-http/Dockerfile @@ -1,5 +1,5 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18-alpine3.16 as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.11 as watchdog +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine as build ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -22,7 +22,6 @@ ARG GOFLAGS="" ARG CGO_ENABLED=0 ENV CGO_ENABLED=${CGO_ENABLED} - # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } @@ -38,10 +37,12 @@ WORKDIR /go/src/handler RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOFLAGS=${GOFLAGS} \ go build --ldflags "-s -w" -a -installsuffix cgo -o handler . -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 as ship +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.1 as ship # Add non root user and certs + RUN apk --no-cache add ca-certificates \ && addgroup -S app && adduser -S -g app app + # Split instructions so that buildkit can run & cache # the previous command ahead of time. RUN mkdir -p /home/app \ diff --git a/template/golang-http/template.yml b/template/golang-http/template.yml index 7259f3d..7986a83 100644 --- a/template/golang-http/template.yml +++ b/template/golang-http/template.yml @@ -1,7 +1,7 @@ language: golang-http fprocess: ./handler welcome_message: | - You have created a new function which uses Go 1.18 and Alpine + You have created a new function which uses Go 1.19 and Alpine Linux as its base image. To disable the go module, for private vendor code, please use diff --git a/template/golang-middleware/Dockerfile b/template/golang-middleware/Dockerfile index 3238ad4..46e2af5 100644 --- a/template/golang-middleware/Dockerfile +++ b/template/golang-middleware/Dockerfile @@ -1,5 +1,5 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18-alpine3.16 as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.11 as watchdog +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine as build ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -34,11 +34,12 @@ WORKDIR /go/src/handler RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build --ldflags "-s -w" -a -installsuffix cgo -o handler . -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 as ship +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.1 as ship # Add non root user and certs RUN apk --no-cache add ca-certificates \ && addgroup -S app && adduser -S -g app app + # Split instructions so that buildkit can run & cache # the previous command ahead of time. RUN mkdir -p /home/app \ diff --git a/template/golang-middleware/template.yml b/template/golang-middleware/template.yml index 029af27..2bb07cb 100644 --- a/template/golang-middleware/template.yml +++ b/template/golang-middleware/template.yml @@ -1,7 +1,7 @@ language: golang-middleware fprocess: ./handler welcome_message: | - You have created a new function which uses Go 1.18 and Alpine + You have created a new function which uses Go 1.19 and Alpine Linux as its base image. To disable the go module, for private vendor code, please use