-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathDockerfile
36 lines (25 loc) · 828 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
FROM golang:1.14-alpine AS build_base
RUN apk --no-cache add tzdata
RUN apk add --no-cache git
# Set the Current Working Directory inside the container
WORKDIR /tmp/go-app
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
# Unit tests
RUN CGO_ENABLED=0 go test ./... -v
# Build the Go app
RUN go build -o ./bin/stygis cmd/main.go
# Start fresh from a smaller image
FROM alpine:3.9
RUN apk add ca-certificates
COPY --from=build_base /tmp/go-app/bin/stygis /app/stygis
COPY --from=build_base /tmp/go-app/static /static
COPY --from=build_base /usr/share/zoneinfo /usr/share/zoneinfo
ENV TZ=Asia/Jakarta
# This container exposes port 8080 to the outside world
EXPOSE 8080
# Run the binary program produced by `go install`
CMD ["/app/stygis"]