Skip to content

Commit 4484ccc

Browse files
committed
serving/samples: fix up README
1 parent e19ebe1 commit 4484ccc

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

docs/serving/samples/hello-world/helloworld-go/Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
# https://hub.docker.com/_/golang
44
FROM golang:1.13 as builder
55

6-
# Copy local code to the container image.
6+
# Create and change to the app directory.
77
WORKDIR /app
8+
9+
# Retrieve application dependencies.
10+
# This allows the container build to reuse cached dependencies.
11+
COPY go.* ./
12+
RUN go mod download
13+
14+
# Copy local code to the container image.
815
COPY . ./
916

1017
# Build the binary.
11-
RUN CGO_ENABLED=0 GOOS=linux go build -v -o helloworld-server
18+
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server
1219

1320
# Use the official Alpine image for a lean production container.
1421
# https://hub.docker.com/_/alpine
@@ -17,7 +24,7 @@ FROM alpine:3
1724
RUN apk add --no-cache ca-certificates
1825

1926
# Copy the binary to the production image from the builder stage.
20-
COPY --from=builder /app/helloworld-server /helloworld-server
27+
COPY --from=builder /app/server /server
2128

2229
# Run the web service on container startup.
23-
CMD ["/helloworld-server"]
30+
CMD ["/server"]

docs/serving/samples/hello-world/helloworld-go/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,19 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-go
7474
# https://hub.docker.com/_/golang
7575
FROM golang:1.13 as builder
7676
77-
# Copy local code to the container image.
77+
# Create and change to the app directory.
7878
WORKDIR /app
79+
80+
# Retrieve application dependencies.
81+
# This allows the container build to reuse cached dependencies.
82+
COPY go.* ./
83+
RUN go mod download
84+
85+
# Copy local code to the container image.
7986
COPY . ./
8087
8188
# Build the binary.
82-
RUN CGO_ENABLED=0 GOOS=linux go build -v -o helloworld-server
89+
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server
8390
8491
# Use the official Alpine image for a lean production container.
8592
# https://hub.docker.com/_/alpine
@@ -88,10 +95,10 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-go
8895
RUN apk add --no-cache ca-certificates
8996
9097
# Copy the binary to the production image from the builder stage.
91-
COPY --from=builder /app/helloworld-server /helloworld-server
98+
COPY --from=builder /app/server /server
9299
93100
# Run the web service on container startup.
94-
CMD ["/helloworld-server"]
101+
CMD ["/server"]
95102
```
96103

97104
1. Create a new file, `service.yaml` and copy the following service definition

0 commit comments

Comments
 (0)