forked from Layr-Labs/eigenda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
148 lines (125 loc) · 4.54 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# syntax=docker/dockerfile:1
# Declare build arguments
# NOTE: to use these args, they must be *consumed* in the child scope (see node-builder)
# https://docs.docker.com/build/building/variables/#scoping
ARG SEMVER=""
ARG GITCOMMIT=""
ARG GITDATE=""
FROM golang:1.21.1-alpine3.18 AS base-builder
RUN apk add --no-cache make musl-dev linux-headers gcc git jq bash
# Common build stage
FROM base-builder AS common-builder
WORKDIR /app
COPY go.mod go.sum ./
COPY disperser /app/disperser
COPY common /app/common
COPY core /app/core
COPY api /app/api
COPY contracts /app/contracts
COPY indexer /app/indexer
COPY encoding /app/encoding
COPY relay /app/relay
COPY inabox /app/inabox
# Churner build stage
FROM common-builder AS churner-builder
COPY operators ./operators
WORKDIR /app/operators
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/churner ./churner/cmd
# Encoder build stage
FROM common-builder AS encoder-builder
WORKDIR /app/disperser
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/encoder ./cmd/encoder
# API Server build stage
FROM common-builder AS apiserver-builder
WORKDIR /app/disperser
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/apiserver ./cmd/apiserver
# DataAPI build stage
FROM common-builder AS dataapi-builder
COPY operators ./operators
WORKDIR /app/disperser
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/dataapi ./cmd/dataapi
# Batcher build stage
FROM common-builder AS batcher-builder
WORKDIR /app/disperser
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/batcher ./cmd/batcher
# Retriever build stage
FROM common-builder AS retriever-builder
COPY retriever /app/retriever
COPY node /app/node
COPY operators ./operators
WORKDIR /app/retriever
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/retriever ./cmd
# Node build stage
FROM common-builder AS node-builder
ARG SEMVER
ARG GITCOMMIT
ARG GITDATE
COPY node /app/node
COPY operators ./operators
WORKDIR /app/node
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags="-X 'github.com/Layr-Labs/eigenda/node.SemVer=${SEMVER}' -X 'github.com/Layr-Labs/eigenda/node.GitCommit=${GITCOMMIT}' -X 'github.com/Layr-Labs/eigenda/node.GitDate=${GITDATE}'" -o ./bin/node ./cmd
# Nodeplugin build stage
FROM common-builder AS node-plugin-builder
COPY ./node /app/node
COPY operators ./operators
WORKDIR /app/node
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/nodeplugin ./plugin/cmd
# Controller build stage
FROM common-builder AS controller-builder
WORKDIR /app/disperser
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/controller ./cmd/controller
# Relay build stage
FROM common-builder AS relay-builder
WORKDIR /app/relay
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/relay ./cmd
# Final stages for each component
FROM alpine:3.18 AS churner
COPY --from=churner-builder /app/operators/bin/churner /usr/local/bin
ENTRYPOINT ["churner"]
FROM alpine:3.18 AS encoder
COPY --from=encoder-builder /app/disperser/bin/encoder /usr/local/bin
ENTRYPOINT ["encoder"]
FROM alpine:3.18 AS apiserver
COPY --from=apiserver-builder /app/disperser/bin/apiserver /usr/local/bin
ENTRYPOINT ["apiserver"]
FROM alpine:3.18 AS dataapi
COPY --from=dataapi-builder /app/disperser/bin/dataapi /usr/local/bin
ENTRYPOINT ["dataapi"]
FROM alpine:3.18 AS batcher
COPY --from=batcher-builder /app/disperser/bin/batcher /usr/local/bin
ENTRYPOINT ["batcher"]
FROM alpine:3.18 AS retriever
COPY --from=retriever-builder /app/retriever/bin/retriever /usr/local/bin
ENTRYPOINT ["retriever"]
FROM alpine:3.18 AS node
COPY --from=node-builder /app/node/bin/node /usr/local/bin
ENTRYPOINT ["node"]
FROM alpine:3.18 AS nodeplugin
COPY --from=node-plugin-builder /app/node/bin/nodeplugin /usr/local/bin
ENTRYPOINT ["nodeplugin"]
FROM alpine:3.18 AS controller
COPY --from=controller-builder /app/disperser/bin/controller /usr/local/bin
ENTRYPOINT ["controller"]
FROM alpine:3.18 AS relay
COPY --from=relay-builder /app/relay/bin/relay /usr/local/bin
ENTRYPOINT ["relay"]