-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (27 loc) · 896 Bytes
/
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
## Will use alpine linux for base image
FROM alpine:3.7 AS builder
LABEL author="[email protected]"
## Uses alpine package manager to install go, git and g++ packages - note sqllite needs g++
RUN apk add go git g++
## Creates an /app directory within the image to hold application source files
RUN mkdir /app
## Copies everything in the root directory into the /app directory
ADD . /app
## Specifies base /app directory
WORKDIR /app
## Downloads dependencies
RUN go get -d -v
## Builds go app
## GCO_ENABLED=1 is due to sqllite
RUN CGO_ENABLED=1 go build -o quotes
## Deletes unecessary packages
RUN apk del go git g++
# Build the second stage (small) image
FROM alpine
WORKDIR /app
COPY --from=builder /app/quotes .
COPY --from=builder /app/quotesqlite .
# Expose port 8080
EXPOSE 8080:8080
## Defines start command which kicks off newly created binary executable
CMD ["/app/quotes"]