Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 17 additions & 11 deletions docs/serving/samples/hello-world/helloworld-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# 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
FROM golang:1.13 as builder

# Create and change to the app directory.
WORKDIR /app

# Retrieve application dependencies.
# This allows the container build to reuse cached dependencies.
COPY go.* ./
RUN go mod download

# Copy local code to the container image.
WORKDIR /go/src/github.com/knative/docs/helloworld
COPY . .
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 helloworld
# Build the binary.
RUN CGO_ENABLED=0 GOOS=linux go build -v -o server

# Use a Docker multi-stage build to create a lean production image.
# Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine
FROM alpine:3
RUN apk add --no-cache ca-certificates

# Copy the binary to the production image from the builder stage.
COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld
COPY --from=builder /app/server /server

# Run the web service on container startup.
CMD ["/helloworld"]
CMD ["/server"]
3 changes: 3 additions & 0 deletions docs/serving/samples/hello-world/helloworld-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/knative/docs/docs/serving/samples/hello-world/helloworld-go

go 1.13
2 changes: 2 additions & 0 deletions test/e2e/sampleapptestbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func prepareWorkDir(t *testing.T, srcDir, workDir string, preCommands []sampleap

func pushDockerImage(t *testing.T, imagePath, workDir string) {
t.Logf("Pushing docker image to: '%s'", imagePath)
t.Logf("image path is: %s", imagePath)
t.Logf("work dir is: %s", workDir)
if output, err := exec.Command("docker", "build", "-t", imagePath, workDir).CombinedOutput(); err != nil {
t.Fatalf("Error building docker image: %v", strings.TrimSpace(string(output)))
}
Expand Down
1 change: 1 addition & 0 deletions test/sampleapp/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ languages:
- "helloworld.go"
- "service.yaml"
- "Dockerfile"
- "go.mod"
- language: "kotlin"
expectedOutput: "Hello Kotlin Sample v1!"
copies:
Expand Down