diff --git a/.dockerignore b/.dockerignore index ccad1e364c..49810fc35b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,12 +2,13 @@ **/__pycache__ **/.pytest_cache -/target -/tmp_check -/tmp_install -/tmp_check_cli -/test_output -/.vscode -/.zenith -/integration_tests/.zenith -/Dockerfile +.git +target +tmp_check +tmp_install +tmp_check_cli +test_output +.vscode +.zenith +integration_tests/.zenith +.mypy_cache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 001adfdbf6..5747438272 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,38 +11,19 @@ WORKDIR /zenith COPY ./vendor/postgres vendor/postgres COPY ./Makefile Makefile RUN make -j $(getconf _NPROCESSORS_ONLN) -s postgres - -# -# Calculate cargo dependencies. -# This will always run, but only generate recipe.json with list of dependencies without -# installing them. -# -FROM zenithdb/build:buster AS cargo-deps-inspect -WORKDIR /zenith -COPY . . -RUN cargo chef prepare --recipe-path /zenith/recipe.json - -# -# Build cargo dependencies. -# This temp cantainner should be rebuilt only if recipe.json was changed. -# -FROM zenithdb/build:buster AS deps-build -WORKDIR /zenith -COPY --from=pg-build /zenith/tmp_install/include/postgresql/server tmp_install/include/postgresql/server -COPY --from=cargo-deps-inspect /usr/local/cargo/bin/cargo-chef /usr/local/cargo/bin/ -COPY --from=cargo-deps-inspect /zenith/recipe.json recipe.json -RUN ROCKSDB_LIB_DIR=/usr/lib/ cargo chef cook --release --recipe-path recipe.json +RUN rm -rf postgres_install/build # # Build zenith binaries # +# TODO: build cargo deps as separate layer. We used cargo-chef before but that was +# net time waste in a lot of cases. Copying Cargo.lock with empty lib.rs should do the work. +# FROM zenithdb/build:buster AS build WORKDIR /zenith -COPY . . -# Copy cached dependencies COPY --from=pg-build /zenith/tmp_install/include/postgresql/server tmp_install/include/postgresql/server -COPY --from=deps-build /zenith/target target -COPY --from=deps-build /usr/local/cargo/ /usr/local/cargo/ + +COPY . . RUN cargo build --release # @@ -51,7 +32,7 @@ RUN cargo build --release FROM debian:buster-slim WORKDIR /data -RUN apt-get update && apt-get -yq install librocksdb-dev libseccomp-dev openssl && \ +RUN apt-get update && apt-get -yq install libreadline-dev libseccomp-dev openssl ca-certificates && \ mkdir zenith_install COPY --from=build /zenith/target/release/pageserver /usr/local/bin diff --git a/Dockerfile.build b/Dockerfile.build index 92b2c21ffd..066bf2226e 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -9,7 +9,7 @@ WORKDIR /zenith # Install postgres and zenith build dependencies # clang is for rocksdb RUN apt-get update && apt-get -yq install automake libtool build-essential bison flex libreadline-dev zlib1g-dev libxml2-dev \ - libseccomp-dev pkg-config libssl-dev librocksdb-dev clang + libseccomp-dev pkg-config libssl-dev clang # Install rust tools -RUN rustup component add clippy && cargo install cargo-chef cargo-audit +RUN rustup component add clippy && cargo install cargo-audit