-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (33 loc) · 995 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
38
39
40
41
42
43
44
45
# Start from golang base image
FROM golang:alpine as builder
# Enable go modules
ENV GO111MODULE=on
# Set current working directory
WORKDIR /app
# Timezone Support
RUN apk --no-cache add tzdata
# Note here: To avoid downloading dependencies every time we
# build image. Here, we are caching all the dependencies by
# first copying go.mod and go.sum files and downloading them,
# to be used every time we build the image if the dependencies
# are not changed.
# Copy go mod and sum files
COPY go.mod ./
COPY go.sum ./
# Download all dependencies.
RUN go mod download
# Now, copy the source code
COPY . .
# Build the application.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/main .
# Finally our multi-stage to build a small image
# Start a new stage from scratch
FROM scratch
# Copy the Pre-built binary file
COPY --from=builder /app/bin/main .
# Timezone settings
ENV TZ=Europe/Budapest
ENV ZONEINFO=/app/config/zoneinfo.zip
# Run executable
EXPOSE 5000
CMD ["./main"]