-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (33 loc) · 1.18 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
45
46
47
# hello-go-deploy-gke example-01 Dockerfile used to build docker image
# Multi-stage build to create a small docker image
#################################
# STAGE 1 build executable binary
#################################
FROM golang:alpine AS builder
# Install git
# Git is required for fetching the dependencies
RUN apk update && apk add --no-cache git
# SET WORKING DIRECTORY AND PLACE YOUR CODE IN
WORKDIR $GOPATH/src/github.com/jeffdecola/hello-go-deploy-gke/
COPY . .
# CHECK
RUN ls -lat $GOPATH/src/github.com/jeffdecola/hello-go-deploy-gke/
# Fetch dependencies using go get
RUN go get -u github.com/sirupsen/logrus
RUN go get -d -v
# Build the binary
RUN go build -o /go/bin/hello-go-deploy-gke main.go
###############################
# STAGE 2 build a smaller image
###############################
FROM alpine
# Add my name to it
LABEL maintainer="Jeff DeCola https://github.com/JeffDeCola/hello-go-deploy-gke"
# Put the binary from previous build into /app
RUN mkdir /app
COPY --from=builder /go/bin/hello-go-deploy-gke /app/hello-go-deploy-gke
WORKDIR /app
# Add the ailibty to /bin/bash in alpine
RUN apk add --update bash
# Run the binary
ENTRYPOINT ["/app/hello-go-deploy-gke"]