mirror of https://github.com/knative/docs.git
update Dockerfile (#1687)
This commit is contained in:
parent
47c837e467
commit
38872ca529
docs/serving/samples/hello-world/helloworld-shell
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue