mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 21:12:55 +00:00
Ansible will soon write the node id to `identity.toml` in the work dir for new pageservers. On the pageserver side, we read the node id from the identity file if it is present and use that as the source of truth. If the identity file is missing, cannot be read, or does not deserialise, start-up is aborted. This PR also removes the `--init` mode and the `--config-override` flag from the `pageserver` binary. The neon_local is already not using these flags anymore. Ansible still uses them until the linked change is merged & deployed, so, this PR has to land simultaneously or after the Ansible change due to that. Related Ansible change: https://github.com/neondatabase/aws/pull/1322 Cplane change to remove config-override usages: https://github.com/neondatabase/cloud/pull/13417 Closes: https://github.com/neondatabase/neon/issues/7736 Overall plan: https://www.notion.so/neondatabase/Rollout-Plan-simplified-pageserver-initialization-f935ae02b225444e8a41130b7d34e4ea?pvs=4 Co-authored-by: Christian Schwarz <christian@neon.tech>
117 lines
5.0 KiB
Docker
117 lines
5.0 KiB
Docker
### Creates a storage Docker image with postgres, pageserver, safekeeper and proxy binaries.
|
|
### The image itself is mainly used as a container for the binaries and for starting e2e tests with custom parameters.
|
|
### By default, the binaries inside the image have some mock parameters and can start, but are not intended to be used
|
|
### inside this image in the real deployments.
|
|
ARG REPOSITORY=neondatabase
|
|
ARG IMAGE=build-tools
|
|
ARG TAG=pinned
|
|
|
|
# Build Postgres
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS pg-build
|
|
WORKDIR /home/nonroot
|
|
|
|
COPY --chown=nonroot vendor/postgres-v14 vendor/postgres-v14
|
|
COPY --chown=nonroot vendor/postgres-v15 vendor/postgres-v15
|
|
COPY --chown=nonroot vendor/postgres-v16 vendor/postgres-v16
|
|
COPY --chown=nonroot pgxn pgxn
|
|
COPY --chown=nonroot Makefile Makefile
|
|
COPY --chown=nonroot scripts/ninstall.sh scripts/ninstall.sh
|
|
|
|
ENV BUILD_TYPE release
|
|
RUN set -e \
|
|
&& mold -run make -j $(nproc) -s neon-pg-ext \
|
|
&& rm -rf pg_install/build \
|
|
&& tar -C pg_install -czf /home/nonroot/postgres_install.tar.gz .
|
|
|
|
# Build neon binaries
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS build
|
|
WORKDIR /home/nonroot
|
|
ARG GIT_VERSION=local
|
|
ARG BUILD_TAG
|
|
|
|
# Enable https://github.com/paritytech/cachepot to cache Rust crates' compilation results in Docker builds.
|
|
# Set up cachepot to use an AWS S3 bucket for cache results, to reuse it between `docker build` invocations.
|
|
# cachepot falls back to local filesystem if S3 is misconfigured, not failing the build
|
|
ARG RUSTC_WRAPPER=cachepot
|
|
ENV AWS_REGION=eu-central-1
|
|
ENV CACHEPOT_S3_KEY_PREFIX=cachepot
|
|
ARG CACHEPOT_BUCKET=neon-github-dev
|
|
#ARG AWS_ACCESS_KEY_ID
|
|
#ARG AWS_SECRET_ACCESS_KEY
|
|
|
|
COPY --from=pg-build /home/nonroot/pg_install/v14/include/postgresql/server pg_install/v14/include/postgresql/server
|
|
COPY --from=pg-build /home/nonroot/pg_install/v15/include/postgresql/server pg_install/v15/include/postgresql/server
|
|
COPY --from=pg-build /home/nonroot/pg_install/v16/include/postgresql/server pg_install/v16/include/postgresql/server
|
|
COPY --from=pg-build /home/nonroot/pg_install/v16/lib pg_install/v16/lib
|
|
COPY --chown=nonroot . .
|
|
|
|
# Show build caching stats to check if it was used in the end.
|
|
# Has to be the part of the same RUN since cachepot daemon is killed in the end of this RUN, losing the compilation stats.
|
|
RUN set -e \
|
|
&& PQ_LIB_DIR=$(pwd)/pg_install/v16/lib RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment" cargo build \
|
|
--bin pg_sni_router \
|
|
--bin pageserver \
|
|
--bin pagectl \
|
|
--bin safekeeper \
|
|
--bin storage_broker \
|
|
--bin storage_controller \
|
|
--bin proxy \
|
|
--bin neon_local \
|
|
--bin storage_scrubber \
|
|
--locked --release \
|
|
&& cachepot -s
|
|
|
|
# Build final image
|
|
#
|
|
FROM debian:bullseye-slim
|
|
WORKDIR /data
|
|
|
|
RUN set -e \
|
|
&& apt update \
|
|
&& apt install -y \
|
|
libreadline-dev \
|
|
libseccomp-dev \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
|
&& useradd -d /data neon \
|
|
&& chown -R neon:neon /data
|
|
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pg_sni_router /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pageserver /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/pagectl /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/safekeeper /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_broker /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_controller /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/proxy /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/neon_local /usr/local/bin
|
|
COPY --from=build --chown=neon:neon /home/nonroot/target/release/storage_scrubber /usr/local/bin
|
|
|
|
COPY --from=pg-build /home/nonroot/pg_install/v14 /usr/local/v14/
|
|
COPY --from=pg-build /home/nonroot/pg_install/v15 /usr/local/v15/
|
|
COPY --from=pg-build /home/nonroot/pg_install/v16 /usr/local/v16/
|
|
COPY --from=pg-build /home/nonroot/postgres_install.tar.gz /data/
|
|
|
|
# By default, pageserver uses `.neon/` working directory in WORKDIR, so create one and fill it with the dummy config.
|
|
# Now, when `docker run ... pageserver` is run, it can start without errors, yet will have some default dummy values.
|
|
RUN mkdir -p /data/.neon/ && \
|
|
echo "id=1234" > "/data/.neon/identity.toml" && \
|
|
echo "broker_endpoint='http://storage_broker:50051'\n" \
|
|
"pg_distrib_dir='/usr/local/'\n" \
|
|
"listen_pg_addr='0.0.0.0:6400'\n" \
|
|
"listen_http_addr='0.0.0.0:9898'\n" \
|
|
> /data/.neon/pageserver.toml && \
|
|
chown -R neon:neon /data/.neon
|
|
|
|
# When running a binary that links with libpq, default to using our most recent postgres version. Binaries
|
|
# that want a particular postgres version will select it explicitly: this is just a default.
|
|
ENV LD_LIBRARY_PATH /usr/local/v16/lib
|
|
|
|
|
|
VOLUME ["/data"]
|
|
USER neon
|
|
EXPOSE 6400
|
|
EXPOSE 9898
|
|
|
|
CMD /usr/local/bin/pageserver -D /data/.neon
|
|
|