-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (41 loc) · 1.41 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## We specify the base image we need for our
## go application
FROM golang:latest as build-env
## We create an /app directory within our
## image that will hold our application source
## files
RUN mkdir /app
## We copy everything in the root directory
## into our /app directory
ADD . /app
## We specify that we now wish to execute
## any further commands inside our /app
## directory
WORKDIR /app
## we run go build to compile the binary
## executable of our Go program
RUN go build -o main .
## Our start command which kicks off
## our newly created binary executable
FROM gcr.io/distroless/base
COPY --from=build-env /app/main /
CMD ["/main"]
## docker build -t go-rest-example .
## docker run -it --name test -p 8080:8080 go-rest-example
# PS C:\Users\sanket> curl http://localhost:8080
# StatusCode : 200
# StatusDescription : OK
# Content : Welcome home!
# RawContent : HTTP/1.1 200 OK
# Content-Length: 13
# Content-Type: text/plain; charset=utf-8
# Date: Tue, 01 Sep 2020 18:37:56 GMT
# Welcome home!
# Forms : {}
# Headers : {[Content-Length, 13], [Content-Type, text/plain; charset=utf-8], [Date, Tue, 01 Sep 2020 18:37:56
# GMT]}
# Images : {}
# InputFields : {}
# Links : {}
# ParsedHtml : mshtml.HTMLDocumentClass
# RawContentLength : 13