forked from BlockPILabs/aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (28 loc) · 997 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
# Build stage
FROM golang:1.22.0-bookworm as builder
RUN apt update && apt install curl unzip -y
ENV GOPATH=/go
WORKDIR /src
# 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 || true
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# Build docker
RUN make static
# Run stage
FROM alpine:3.13 as production
RUN apk --no-cache add ca-certificates tzdata htop tini bash curl
RUN rm -rf /tmp/*
# Change timezone to UTC/GMT
ENV TZ=UTC
RUN cp /usr/share/zoneinfo/UTC /etc/localtime
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /src/out /bin/
# Health check
HEALTHCHECK --interval=30s --timeout=30s --retries=5 --start-period=30s CMD curl -f http://localhost:8012/status || exit 1
# Expose ports
EXPOSE 8011 8012
# Command to run the executable
CMD ["tini", "--", "/bin/aggregator"]