Apache DataFusion SQL Query Engine
ARROW-7136: [Rust] Added caching to the docker image
Krisztián Szűcsf1f2df026e9b
diff --git a/.dockerignore b/.dockerignoreindex d76d1c56b9..083905c743 100644--- a/.dockerignore+++ b/.dockerignore@@ -48,3 +48,13 @@!ruby/red-plasma/Gemfile!ruby/red-plasma/lib/plasma/version.rb!ruby/red-plasma/red-plasma.gemspec+!rust/Cargo.toml+!rust/benchmarks/Cargo.toml+!rust/arrow/Cargo.toml+!rust/arrow/benches+!rust/arrow-flight/Cargo.toml+!rust/parquet/Cargo.toml+!rust/parquet/build.rs+!rust/datafusion/Cargo.toml+!rust/datafusion/benches+!rust/integration-testing/Cargo.tomldiff --git a/.github/workflows/rust.yml b/.github/workflows/rust.ymlindex 15c5e44cfd..89724a0a41 100644--- a/.github/workflows/rust.yml+++ b/.github/workflows/rust.yml@@ -64,6 +64,12 @@ jobs:- name: Free Up Disk Spaceshell: bashrun: ci/scripts/util_cleanup.sh+ - name: Cache Docker Volumes+ uses: actions/cache@v1+ with:+ path: .docker+ key: debian-10-rust-${{ hashFiles('rust/**.rs') }}+ restore-keys: debian-10-rust-- name: Setup Pythonuses: actions/setup-python@v1with:@@ -75,6 +81,8 @@ jobs:sudo sysctl -w kernel.core_pattern="core.%e.%p"ulimit -c unlimitedarchery docker run debian-rust+ - name: Fix Cache Permissions+ run: sudo chmod -R o+r .docker- name: Docker Pushif: success() && github.event_name == 'push' && github.repository == 'apache/arrow'continue-on-error: true@@ -106,6 +114,12 @@ jobs:- name: Fetch Submodules and Tagsshell: bashrun: ci/scripts/util_checkout.sh+ - name: Cache Build Artifacts+ uses: actions/cache@v1+ with:+ path: rust/target+ key: windows-rust-${{ hashFiles('rust/**.rs') }}+ restore-keys: windows-rust-- name: Buildshell: bashrun: ci/scripts/rust_build.sh $(pwd) $(pwd)/build@@ -138,6 +152,12 @@ jobs:- name: Fetch Submodules and Tagsshell: bashrun: ci/scripts/util_checkout.sh+ - name: Cache Build Artifacts+ uses: actions/cache@v1+ with:+ path: rust/target+ key: macos-10-rust-${{ hashFiles('rust/**.rs') }}+ restore-keys: macos-10-rust-- name: Run Clippyshell: bashrun: ci/scripts/rust_lint.sh $(pwd)diff --git a/ci/docker/debian-10-rust.dockerfile b/ci/docker/debian-10-rust.dockerfileindex 44f012319f..b23b03c9a1 100644--- a/ci/docker/debian-10-rust.dockerfile+++ b/ci/docker/debian-10-rust.dockerfile@@ -29,17 +29,43 @@ ARG flatbuffers=1.11.0RUN wget -q -O - https://github.com/google/flatbuffers/archive/v${flatbuffers}.tar.gz | tar -xzf - && \cd flatbuffers-${flatbuffers} && \cmake -G "Unix Makefiles" && \- make install && \+ make install -j4 && \cd / && \rm -rf flatbuffers-${flatbuffers}-# sadly cargo doesn't have a command to fetch and build the-# dependencies without building the library itselfARG rust=nightly-2020-04-22-RUN rustup default ${rust}-RUN rustup component add rustfmt --toolchain ${rust}-x86_64-unknown-linux-gnu-# TODO(kszucs):-# 1. add the files required to install the dependencies to .dockerignore-# 2. copy these files to their appropriate path-# 3. download and compile the dependencies+# freeze the version for deterministic builds+RUN rustup default ${rust} && \+ rustup component add rustfmt --toolchain ${rust}-x86_64-unknown-linux-gnu++# Compile a dummy program, so that the dependencies are compiled and cached on a layer+# see https://stackoverflow.com/a/58474618/931303 for details+# We do not compile any of the workspace or we defeat the purpose of caching - we only+# compile their external dependencies.++ENV CARGO_HOME="/rust/cargo" \+ CARGO_TARGET_DIR="/rust/target" \+ RUSTFLAGS="-D warnings"++# The artifact of the steps below is a "${CARGO_TARGET_DIR}" containing+# compiled dependencies. Create the directories and place an empty lib.rs+# files.+COPY rust /arrow/rust+RUN mkdir \+ /arrow/rust/arrow-flight/src \+ /arrow/rust/arrow/src \+ /arrow/rust/benchmarks/src \+ /arrow/rust/datafusion/src \+ /arrow/rust/integration-testing/src \+ /arrow/rust/parquet/src && \+ touch \+ /arrow/rust/arrow-flight/src/lib.rs \+ /arrow/rust/arrow/src/lib.rs \+ /arrow/rust/benchmarks/src/lib.rs \+ /arrow/rust/datafusion/src/lib.rs \+ /arrow/rust/integration-testing/src/lib.rs \+ /arrow/rust/parquet/src/lib.rs++# Compile dependencies for the whole workspace+RUN cd /arrow/rust && cargo build --workspace --lib --all-featuresdiff --git a/ci/scripts/rust_build.sh b/ci/scripts/rust_build.shindex 7bbef28760..bdea5e44f6 100755--- a/ci/scripts/rust_build.sh+++ b/ci/scripts/rust_build.sh@@ -23,7 +23,6 @@ source_dir=${1}/rustexport ARROW_TEST_DATA=${arrow_dir}/testing/dataexport PARQUET_TEST_DATA=${arrow_dir}/cpp/submodules/parquet-testing/data-export RUSTFLAGS="-D warnings"# show activated toolchainrustup showdiff --git a/ci/scripts/rust_test.sh b/ci/scripts/rust_test.shindex 8fcb453384..254ea43d29 100755--- a/ci/scripts/rust_test.sh+++ b/ci/scripts/rust_test.sh@@ -21,12 +21,9 @@ set -exarrow_dir=${1}source_dir=${1}/rust-build_dir=${2}/rustexport ARROW_TEST_DATA=${arrow_dir}/testing/dataexport PARQUET_TEST_DATA=${arrow_dir}/cpp/submodules/parquet-testing/data-export CARGO_TARGET_DIR=${build_dir}-export RUSTFLAGS="-D warnings"pushd ${source_dir}diff --git a/docker-compose.yml b/docker-compose.ymlindex 1828adf9f8..82e06d7c3e 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -941,11 +941,15 @@ services:rust: ${RUST}shm_size: *shm-sizeenvironment:- CARGO_HOME: /build/cargo- volumes: *debian-volumes+ CARGO_HOME: /rust/cargo+ CARGO_TARGET_DIR: /build/rust+ volumes: &rust-volumes+ - .:/arrow:delegated+ - ${DOCKER_VOLUME_DIRECTORY:-.docker}/${ARCH}-debian-${DEBIAN}-rust:/build:delegatedcommand: &rust-command >/bin/bash -c "echo ${RUST} > /arrow/rust/rust-toolchain &&+ if [ ! -d "/build/rust" ]; then mv /rust/target /build/rust; fi &&/arrow/ci/scripts/rust_build.sh /arrow /build &&/arrow/ci/scripts/rust_test.sh /arrow /build"