Skip to content
Draft
109 changes: 109 additions & 0 deletions scripts/build/chainlink.Dockerfile
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
Copy link

Copilot AI Sep 10, 2025

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, use COPY ./ccip/config /ccip-config instead.

Suggested change
COPY ./cci[p]/confi[g] /ccip-config
COPY ./ccip/config /ccip-config

Copilot uses AI. Check for mistakes.

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"]
Loading