-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor to single multistage dockerfile with bake file #754
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Declare build arguments | ||
# TODO: this is only used for node image right now, should we also use it for nodeplugin? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we should use it for all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just checked, nodeplugin doesn't even define those variables. Let's do it in a separate PR if it's ever needed. Probably add it to all binaries in one go. |
||
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 | ||
|
||
# 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 | ||
|
||
# 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/churner /app/operators/churner | ||
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 | ||
COPY node /app/node | ||
COPY operators/churner /app/operators/churner | ||
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/churner /app/operators/churner | ||
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 | ||
|
||
|
||
# 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 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"] |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# VARIABLES | ||
|
||
variable "BUILD_TAG" { | ||
default = "latest" | ||
} | ||
|
||
variable "SEMVER" { | ||
default = "v0.0.0" | ||
} | ||
|
||
variable "GITCOMMIT" { | ||
default = "dev" | ||
} | ||
|
||
variable "GITDATE" { | ||
default = "0" | ||
} | ||
|
||
# GROUPS | ||
|
||
group "default" { | ||
targets = ["all"] | ||
} | ||
|
||
group "all" { | ||
targets = ["node-group", "disperser-group"] | ||
} | ||
|
||
group "node-group" { | ||
targets = ["node", "nodeplugin"] | ||
} | ||
|
||
group "disperser-group" { | ||
targets = ["batcher", "disperser", "encoder", "retriever", "churner"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically retriever and churner are not part of disperser There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah good point will leave them as separate individual targets then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
group "node-group-release" { | ||
targets = ["node-release", "nodeplugin-release"] | ||
} | ||
|
||
# DISPERSER TARGETS | ||
|
||
target "batcher" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "batcher" | ||
tags = ["ghcr.io/layr-labs/eigenda/batcher:${BUILD_TAG}"] | ||
} | ||
|
||
target "disperser" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "apiserver" | ||
tags = ["ghcr.io/layr-labs/eigenda/disperser:${BUILD_TAG}"] | ||
} | ||
|
||
target "encoder" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "encoder" | ||
tags = ["ghcr.io/layr-labs/eigenda/encoder:${BUILD_TAG}"] | ||
} | ||
|
||
target "retriever" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "retriever" | ||
tags = ["ghcr.io/layr-labs/eigenda/retriever:${BUILD_TAG}"] | ||
} | ||
|
||
target "churner" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "churner" | ||
tags = ["ghcr.io/layr-labs/eigenda/churner:${BUILD_TAG}"] | ||
} | ||
|
||
# NODE TARGETS | ||
|
||
target "node" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "node" | ||
tags = ["ghcr.io/layr-labs/eigenda/node:${BUILD_TAG}"] | ||
args = { | ||
SEMVER = "${SEMVER}" | ||
GITCOMMIT = "${GITCOMMIT}" | ||
GITDATE = "${GITDATE}" | ||
} | ||
} | ||
|
||
target "nodeplugin" { | ||
context = "." | ||
dockerfile = "./Dockerfile" | ||
target = "nodeplugin" | ||
tags = ["ghcr.io/layr-labs/eigenda/nodeplugin:${BUILD_TAG}"] | ||
} | ||
|
||
# RELEASE TARGETS | ||
|
||
target "_release" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like it's not private, since you can still print it with |
||
platforms = ["linux/amd64", "linux/arm64"] | ||
} | ||
|
||
target "node-release" { | ||
inherits = ["node", "_release"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the image built by release should be in format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
target "nodeplugin-release" { | ||
inherits = ["nodeplugin", "_release"] | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of making it a separate workflow and then deprecating this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel it's not needed. If ever we have a problem with this we can git revert the PR.