Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions template/golang-http/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ 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; }


WORKDIR /go/src/handler/function
RUN mkdir -p /go/src/handler/function/static

RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test ./... -cover

WORKDIR /go/src/handler
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build --ldflags "-s -w" -a -installsuffix cgo -o handler .

FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.14
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.15
# Add non root user and certs
RUN apk --no-cache add ca-certificates \
&& addgroup -S app && adduser -S -g app app
Expand All @@ -46,9 +46,9 @@ RUN mkdir -p /home/app \

WORKDIR /home/app

COPY --from=build --chown=app /go/src/handler/handler .
COPY --from=build --chown=app /usr/bin/fwatchdog .
COPY --from=build --chown=app /go/src/handler/function/ .
COPY --from=build --chown=app /go/src/handler/handler .
COPY --from=build --chown=app /usr/bin/fwatchdog .
COPY --from=build --chown=app /go/src/handler/function/static static

USER app

Expand Down
10 changes: 6 additions & 4 deletions template/golang-middleware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ ENV CGO_ENABLED=${CGO_ENABLED}
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; }

WORKDIR /go/src/handler/function
RUN mkdir -p /go/src/handler/function/static

RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test ./... -cover

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.14
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.15 as ship

# Add non root user and certs
RUN apk --no-cache add ca-certificates \
&& addgroup -S app && adduser -S -g app app
Expand All @@ -44,9 +46,9 @@ RUN mkdir -p /home/app \

WORKDIR /home/app

COPY --from=build --chown=app /go/src/handler/handler .
COPY --from=build --chown=app /usr/bin/fwatchdog .
COPY --from=build --chown=app /go/src/handler/function/ .
COPY --from=build --chown=app /go/src/handler/handler .
COPY --from=build --chown=app /usr/bin/fwatchdog .
COPY --from=build --chown=app /go/src/handler/function/static static

USER app

Expand Down