Skip to content

Commit

Permalink
Update to Go 1.19 and Alpine 3.17
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Jan 24, 2023
1 parent 4c89dc9 commit e490943
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions template/golang-http/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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; }

Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion template/golang-http/template.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions template/golang-middleware/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion template/golang-middleware/template.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e490943

Please sign in to comment.