-
Notifications
You must be signed in to change notification settings - Fork 2
[WIP] Chainlink image builder #178
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
Draft
krebernisak
wants to merge
9
commits into
main
Choose a base branch
from
feat/chainlink-builder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
19054b7
Start with base core plugins/chainlink.Dockerfile
krebernisak 255404b
Update builders, add detect-plugins-prep-env-setup.sh + entrypoint
krebernisak 882b8ce
Rename Dockerfiles
krebernisak 44df34b
Simplify COPY, fix entrypoint-chainlink.sh name
krebernisak 8af38ba
Add solana and aptos plugin builds
krebernisak 5ae2bc0
Add (local) chainlink-ton to the bundle
krebernisak b4c351a
Standardize chainlink-ton build
krebernisak 3ec8219
Fix NIX_BUILD_PKG build arg
krebernisak f88449b
Nixify chainlink build
krebernisak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
## | ||
# Build image: Chainlink binary with plugins for testing purposes only. | ||
# XXX: Experimental -- not to be used to build images for production use. | ||
# See: ../core/chainlink.Dockerfile for the production Dockerfile. | ||
## | ||
FROM golang:1.24-bullseye AS buildgo | ||
RUN go version | ||
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /chainlink | ||
|
||
COPY GNUmakefile package.json ./ | ||
COPY tools/bin/ldflags ./tools/bin/ | ||
|
||
ADD go.mod go.sum ./ | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
COPY . . | ||
|
||
# Install Delve for debugging with cache mounts | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
go install github.com/go-delve/delve/cmd/[email protected] | ||
|
||
# Flag to control installation of private plugins (default: false). | ||
ARG CL_INSTALL_PRIVATE_PLUGINS=false | ||
# Flag to control installation of testing plugins (default: false). | ||
ARG CL_INSTALL_TESTING_PLUGINS=false | ||
# Flags for Go Delve debugger | ||
ARG GO_GCFLAGS | ||
# Env vars needed for chainlink build | ||
ARG COMMIT_SHA | ||
|
||
ENV CL_LOOPINSTALL_OUTPUT_DIR=/tmp/loopinstall-output | ||
RUN --mount=type=secret,id=GIT_AUTH_TOKEN \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
./plugins/scripts/setup_git_auth.sh && \ | ||
mkdir -p /gobins && mkdir -p "${CL_LOOPINSTALL_OUTPUT_DIR}" && \ | ||
GOBIN=/go/bin make install-loopinstall && \ | ||
GOBIN=/gobins CL_LOOPINSTALL_OUTPUT_DIR=${CL_LOOPINSTALL_OUTPUT_DIR} make install-plugins-local install-plugins-public && \ | ||
if [ "${CL_INSTALL_PRIVATE_PLUGINS}" = "true" ]; then \ | ||
GOBIN=/gobins CL_LOOPINSTALL_OUTPUT_DIR=${CL_LOOPINSTALL_OUTPUT_DIR} make install-plugins-private; \ | ||
fi && \ | ||
if [ "${CL_INSTALL_TESTING_PLUGINS}" = "true" ]; then \ | ||
GOBIN=/gobins CL_LOOPINSTALL_OUTPUT_DIR=${CL_LOOPINSTALL_OUTPUT_DIR} make install-plugins-testing; \ | ||
fi | ||
|
||
# Copy any shared libraries. | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
mkdir -p /tmp/lib && \ | ||
./plugins/scripts/copy_loopinstall_libs.sh \ | ||
"$CL_LOOPINSTALL_OUTPUT_DIR" \ | ||
/tmp/lib | ||
|
||
# Build chainlink. | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
GOBIN=/gobins make GO_GCFLAGS="${GO_GCFLAGS}" install-chainlink | ||
|
||
## | ||
# Final Image | ||
## | ||
FROM ubuntu:24.04 | ||
|
||
ARG CHAINLINK_USER=root | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get install -y ca-certificates gnupg lsb-release curl && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Postgres for CLI tools, needed specifically for DB backups | ||
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ | ||
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list \ | ||
&& apt-get update && apt-get install -y postgresql-client-16 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN if [ ${CHAINLINK_USER} != root ]; then useradd --uid 14933 --create-home ${CHAINLINK_USER}; fi | ||
USER ${CHAINLINK_USER} | ||
|
||
# Copy Delve debugger from build stage. | ||
COPY --from=buildgo /go/bin/dlv /usr/local/bin/dlv | ||
|
||
# Set plugin environment variable configuration. | ||
ENV CL_MEDIAN_CMD=chainlink-feeds | ||
ARG CL_SOLANA_CMD=chainlink-solana | ||
ENV CL_SOLANA_CMD=${CL_SOLANA_CMD} | ||
# Experimental environment variables: | ||
ENV CL_EVM_CMD=chainlink-evm | ||
ENV CL_MERCURY_CMD=chainlink-mercury | ||
|
||
# CCIP specific | ||
COPY ./cci[p]/confi[g] /ccip-config | ||
ARG CL_CHAIN_DEFAULTS | ||
ENV CL_CHAIN_DEFAULTS=${CL_CHAIN_DEFAULTS} | ||
|
||
# Copy the binaries from the build stage (plugins + chainlink). | ||
COPY --from=buildgo /gobins/ /usr/local/bin/ | ||
# Copy shared libraries from the build stage. | ||
COPY --from=buildgo /tmp/lib /usr/lib/ | ||
|
||
WORKDIR /home/${CHAINLINK_USER} | ||
|
||
# Explicitly set the cache dir. Needed so both root and non-root user has an explicit location. | ||
ENV XDG_CACHE_HOME=/home/${CHAINLINK_USER}/.cache | ||
RUN mkdir -p ${XDG_CACHE_HOME} | ||
|
||
EXPOSE 6688 | ||
ENTRYPOINT ["chainlink"] | ||
HEALTHCHECK CMD curl -f http://localhost:6688/health || exit 1 | ||
CMD ["local", "node"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The glob pattern with square brackets
cci[p]/confi[g]
will match literal characters 'p' and 'g' respectively, not the full words 'ccip/config'. If you intend to copy the ccip/config directory, useCOPY ./ccip/config /ccip-config
instead.Copilot uses AI. Check for mistakes.