Skip to content

Commit c6c867d

Browse files
committed
Allow static files to be published into final image
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 1e91dec commit c6c867d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

template/golang-http/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ ENV CGO_ENABLED=${CGO_ENABLED}
2626
# Run a gofmt and exclude all vendored code.
2727
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; }
2828

29-
3029
WORKDIR /go/src/handler/function
30+
RUN mkdir -p /go/src/handler/function/static
3131

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

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

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

4747
WORKDIR /home/app
4848

49-
COPY --from=build --chown=app /go/src/handler/handler .
50-
COPY --from=build --chown=app /usr/bin/fwatchdog .
51-
COPY --from=build --chown=app /go/src/handler/function/ .
49+
COPY --from=build --chown=app /go/src/handler/handler .
50+
COPY --from=build --chown=app /usr/bin/fwatchdog .
51+
COPY --from=build --chown=app /go/src/handler/function/static static
5252

5353
USER app
5454

template/golang-middleware/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ ENV CGO_ENABLED=${CGO_ENABLED}
2626
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; }
2727

2828
WORKDIR /go/src/handler/function
29+
RUN mkdir -p /go/src/handler/function/static
2930

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

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

36-
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.14
37+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.15 as ship
38+
3739
# Add non root user and certs
3840
RUN apk --no-cache add ca-certificates \
3941
&& addgroup -S app && adduser -S -g app app
@@ -44,9 +46,9 @@ RUN mkdir -p /home/app \
4446

4547
WORKDIR /home/app
4648

47-
COPY --from=build --chown=app /go/src/handler/handler .
48-
COPY --from=build --chown=app /usr/bin/fwatchdog .
49-
COPY --from=build --chown=app /go/src/handler/function/ .
49+
COPY --from=build --chown=app /go/src/handler/handler .
50+
COPY --from=build --chown=app /usr/bin/fwatchdog .
51+
COPY --from=build --chown=app /go/src/handler/function/static static
5052

5153
USER app
5254

0 commit comments

Comments
 (0)