-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
35 lines (26 loc) · 1.03 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
# Start from the latest golang base image
# Start from the latest golang base image
FROM golang:latest
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# Expose port 8080 to the outside world
EXPOSE 8080
RUN GIT_COMMIT=$(git rev-parse --short HEAD 2> /dev/null || true) \
&& BUILDTIME=$(TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ') \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/labbsr0x/go-horse/config.GitCommit=${GIT_COMMIT} \
-X github.com/labbsr0x/go-horse/config.BuildTime=${BUILDTIME}" \
-a -installsuffix cgo -o /main
FROM scratch
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /main /
# Command to set main program
ENTRYPOINT ["./main"]
# Serve command to run api
CMD ["serve"]