diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..60d59d505888 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +*target** +.git +/test_dir* diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml index 6685f1e295ee..c97867e84c6e 100644 --- a/.github/workflows/ci-rust.yml +++ b/.github/workflows/ci-rust.yml @@ -15,19 +15,14 @@ jobs: steps: - uses: actions/checkout@v1 - # TODO revisit this, workaround for now - - name: Install OpenCL - run: sudo apt install ocl-icd-opencl-dev + - name: Pull serialization vectors + run: git submodule update --init - - name: Toolchain setup - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - name: Build CI docker image + run: docker build -t forest/rust:latest -f ./Dockerfile-ci . - - name: Cargo test all - run: make test-all + - name: Test all + run: docker run forest/rust cargo test --all-features fmt: name: rustfmt @@ -58,9 +53,6 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Install OpenCL - run: sudo apt install ocl-icd-opencl-dev - - name: Cache cargo registry uses: actions/cache@v1 with: @@ -109,9 +101,6 @@ jobs: - name: Install Rust run: rustup update beta && rustup default beta - - name: Install OpenCL - run: sudo apt install ocl-icd-opencl-dev - - name: Build documentation run: cargo doc --no-deps --all-features - name: Publish documentation diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..0cd91ac58f6f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# This Dockerfile is for the main forest binary +# Example usage: +# docker build -t forest:latest -f ./Dockerfile . +# docker run forest + +FROM rust:1.42-stretch AS build-env + +WORKDIR /usr/src/forest +COPY . . + +# Extra dependencies needed for rust-fil-proofs +RUN apt-get update && \ + apt-get install -y curl file gcc g++ git make openssh-client \ + autoconf automake cmake libtool libcurl4-openssl-dev libssl-dev \ + libelf-dev libdw-dev binutils-dev zlib1g-dev libiberty-dev wget \ + xz-utils pkg-config python clang ocl-icd-opencl-dev + +RUN cargo install --path forest + +# Prod image for forest binary +FROM debian:buster-slim + +# Copy over binaries from the build-env +COPY --from=build-env /usr/local/cargo/bin/forest /usr/local/bin/forest + +CMD ["forest"] diff --git a/Dockerfile-ci b/Dockerfile-ci new file mode 100644 index 000000000000..ae34e1658777 --- /dev/null +++ b/Dockerfile-ci @@ -0,0 +1,20 @@ +# This Dockerfile is used for consistent build environment in CI +# Example usage: +# docker build -t forest/rust:latest -f ./Dockerfile-ci . +# docker run forest/rust cargo c + +FROM rust:1.42-stretch + +WORKDIR /usr/src/forest +COPY . . + +# Extra dependencies needed for rust-fil-proofs +RUN apt-get update && \ + apt-get install -y curl file gcc g++ git make openssh-client \ + autoconf automake cmake libtool libcurl4-openssl-dev libssl-dev \ + libelf-dev libdw-dev binutils-dev zlib1g-dev libiberty-dev wget \ + xz-utils pkg-config python clang ocl-icd-opencl-dev + +RUN bash -l -c 'echo $(rustc --print sysroot)/lib >> /etc/ld.so.conf' +RUN bash -l -c 'echo /usr/local/lib >> /etc/ld.so.conf' +RUN ldconfig diff --git a/Makefile b/Makefile index 1c2fcac99783..2242655b3f5d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ SER_TESTS = "tests/serialization_tests" +install: + cargo install --path forest --force + clean-all: cargo clean @@ -35,14 +38,11 @@ lint: license clean cargo fmt --all cargo clippy -- -D warnings -install: - cargo install --path forest --force - build: - cargo build + cargo build --bin forest release: - cargo build --release + cargo build --release --bin forest # Git submodule test vectors pull-serialization-tests: diff --git a/scripts/add_license.sh b/scripts/add_license.sh index de99d238fede..cc1e45be4044 100755 --- a/scripts/add_license.sh +++ b/scripts/add_license.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/sh PAT_APA="^// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT$"