Skip to content

Commit e11b3e0

Browse files
Fix issue kubernetes#540: Change the go version 1.10 -> 1.20 and adding the missing go.mod and go.sum files.
1 parent 574ea58 commit e11b3e0

File tree

3 files changed

+58
-21
lines changed

3 files changed

+58
-21
lines changed

guestbook-go/Dockerfile

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
# Copyright 2016 The Kubernetes Authors.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
FROM golang:1.10.0
16-
RUN go get github.com/codegangsta/negroni \
17-
github.com/gorilla/mux \
18-
github.com/xyproto/simpleredis/v2
1+
# Use Go 1.18 base image
2+
FROM golang:1.18 AS builder
3+
4+
# Set the working directory
195
WORKDIR /app
20-
ADD ./main.go .
6+
7+
# Copy Go module files and download dependencies
8+
COPY go.mod go.sum ./
9+
RUN go mod download
10+
11+
# Copy the source code and build the application
12+
COPY main.go ./
2113
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
2214

15+
# Use a minimal base image to keep the final image small
2316
FROM scratch
17+
18+
# Set the working directory
2419
WORKDIR /app
25-
COPY --from=0 /app/main .
20+
21+
# Copy the built binary from the builder stage
22+
COPY --from=builder /app/main .
23+
24+
# Copy static files
2625
COPY ./public/index.html public/index.html
2726
COPY ./public/script.js public/script.js
2827
COPY ./public/style.css public/style.css
28+
29+
# Define the command to run the application
2930
CMD ["/app/main"]
30-
EXPOSE 3000
31+
32+
# Expose the port on which the application will run
33+
EXPOSE 3000

guestbook-go/go.mod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Guestbook
2+
3+
go 1.20
4+
5+
require (
6+
github.com/codegangsta/negroni v1.0.0
7+
github.com/gorilla/mux v1.8.1
8+
github.com/xyproto/simpleredis/v2 v2.6.5
9+
)
10+
11+
require (
12+
github.com/gomodule/redigo v1.8.9 // indirect
13+
github.com/xyproto/pinterface v1.5.3 // indirect
14+
)

guestbook-go/go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
github.com/codegangsta/negroni v1.0.0 h1:+aYywywx4bnKXWvoWtRfJ91vC59NbEhEY03sZjQhbVY=
2+
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
3+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
4+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
6+
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
7+
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
8+
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
9+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
10+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
12+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
13+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
14+
github.com/xyproto/pinterface v1.5.3 h1:RKkNT88cwrSqD9hU4cYAO5yeo8srg4TG+74Pcj88iz0=
15+
github.com/xyproto/pinterface v1.5.3/go.mod h1:X5B5pKE49ak7SpyDh5QvJvLH9cC9XuZNDcl5hEyYc34=
16+
github.com/xyproto/simpleredis/v2 v2.6.5 h1:PtAz5j2UUACNHx5LetI60dbCsVMhIv1H878bND4VQK4=
17+
github.com/xyproto/simpleredis/v2 v2.6.5/go.mod h1:OrWVubZGr0SbpAjkAQkFn/iiex2AsblBm80uhYxbjQY=
18+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
19+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
20+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)