-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
41 lines (33 loc) · 924 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
#
# Prepare stage.
#
FROM golang:1.21-alpine AS prepare
WORKDIR /app
# Copy the go.mod and go.sum first and download the dependencies.
# This layer will be cached unless these files change.
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
go mod download
#
# Build stage.
#
FROM prepare AS build
WORKDIR /app
# Install build dependencies required for CGO
RUN apk add --no-cache musl-dev gcc g++ libstdc++
# Copy the rest of the source code
COPY . .
# Build the binary with caching
ENV CGO_ENABLED=1
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
go build -o /bin/ssv-rewards ./cmd/ssv-rewards
#
# Run stage.
#
FROM alpine:3.18
WORKDIR /app
# Copy the built binary from the previous stage
COPY --from=build /bin/ssv-rewards /bin/ssv-rewards
ENTRYPOINT ["/bin/ssv-rewards"]