update Dockerfile ()

This commit is contained in:
Averi Kitsch 2019-08-26 10:23:16 -07:00 committed by Knative Prow Robot
parent 47c837e467
commit 38872ca529
2 changed files with 44 additions and 12 deletions
docs/serving/samples/hello-world/helloworld-shell

View File

@ -1,10 +1,26 @@
FROM golang:1.11
WORKDIR /go/src/invoke
# Use the offical Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.12 as builder
# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/helloworld-shell
COPY invoke.go .
RUN go install -v
COPY . .
# Build the command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN CGO_ENABLED=0 GOOS=linux go build -v -o invoke
CMD ["invoke"]
# The official Alpine base image
# https://hub.docker.com/_/alpine
# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3.10
# Copy Go binary
COPY --from=builder /go/src/github.com/knative/docs/helloworld-shell/invoke /invoke
COPY script.sh .
# Run the web service on container startup.
CMD ["/invoke"]

View File

@ -74,16 +74,32 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-shell
1. Create a new file named `Dockerfile` and copy the code block below into it.
```docker
FROM golang:1.11
WORKDIR /go/src/invoke
# Use the offical Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.12 as builder
# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/helloworld-shell
COPY invoke.go .
RUN go install -v
COPY . .
# Build the command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN CGO_ENABLED=0 GOOS=linux go build -v -o invoke
CMD ["invoke"]
# The official Alpine base image
# https://hub.docker.com/_/alpine
# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3.10
# Copy Go binary
COPY --from=builder /go/src/github.com/knative/docs/helloworld-shell/invoke /invoke
COPY script.sh .
# Run the web service on container startup.
CMD ["/invoke"]
```
1. Create a new file, `service.yaml` and copy the following service definition