From 04765a78a6c81d326361cc9ba82a39c3e7eec335 Mon Sep 17 00:00:00 2001 From: colbyn Date: Sat, 16 Nov 2019 17:59:01 -0700 Subject: [PATCH] imager bin pre-release setup --- bin/.dockerignore | 3 ++ bin/.gitignore | 1 + bin/Dockerfile | 54 +++++++++++++++++------------------- bin/scripts/build-release.sh | 33 +++++++++++++++++++++- bin/scripts/docker/build.sh | 8 ++---- 5 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 bin/.dockerignore create mode 100644 bin/.gitignore diff --git a/bin/.dockerignore b/bin/.dockerignore new file mode 100644 index 0000000..833ae37 --- /dev/null +++ b/bin/.dockerignore @@ -0,0 +1,3 @@ +target/ +**/assets/output/ +**/assets/samples/ \ No newline at end of file diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..ae02570 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +release/ \ No newline at end of file diff --git a/bin/Dockerfile b/bin/Dockerfile index 1f27525..0ceed3b 100644 --- a/bin/Dockerfile +++ b/bin/Dockerfile @@ -3,19 +3,17 @@ ############################################################################### FROM rust:latest as build -# SYSTEM DEPENDENCIES +# SETUP +WORKDIR /code/ RUN apt-get -y update && \ apt-get -y upgrade && \ apt-get -y install build-essential software-properties-common curl git vim tree -# PROJECT DEPENDENCIES - CORE -RUN apt-get install -y llvm-dev libclang-dev clang - -# PROJECT DEPENDENCIES -WORKDIR /code/ -RUN apt-get install -y openssl pkg-config libssl-dev && apt-get clean +# SYSTEM DEPENDENCIES +RUN apt-get install -y llvm-dev libclang-dev clang openssl pkg-config libssl-dev +# BUILD PROJECT DEPENDENCIES FIRST RUN mkdir -p imager-cli/src imager-server/src RUN echo 'fn main() {panic!("stub")}' > imager-cli/src/main.rs RUN echo 'fn main() {panic!("stub")}' > imager-server/src/main.rs @@ -23,31 +21,31 @@ ADD Cargo.toml . ADD imager-cli/Cargo.toml imager-cli/Cargo.toml ADD imager-server/Cargo.toml imager-server/Cargo.toml RUN cargo build --release -RUN cargo test - -# # PROJECT ASSETS -# ADD ./assets/test ./assets/test -# # PROJECT APPLICATION -# RUN rm ./target/release/deps/imager* -# ADD ./src/ ./src/ -# RUN cargo test -# RUN cargo build --release +# BUILD PROJECT CODE +RUN rm target/release/deps/imager-* && \ + rm target/release/deps/imager_server-* +ADD imager-cli/src imager-cli/src +ADD imager-server/src imager-server/src +RUN cargo build --release -# # INSTALL -# RUN cargo install --force --path . +# INSTALL +RUN cargo install --force --path imager-cli && \ + cargo install --force --path imager-server -# ############################################################################### -# # RUNTIME ENVIRONMENT -# ############################################################################### -# FROM ubuntu:18.04 as runtime +############################################################################### +# RUNTIME ENVIRONMENT +############################################################################### +FROM ubuntu:18.04 as runtime -# # SETUP -# RUN apt-get -y update && \ -# apt-get -y upgrade && \ -# apt-get -y install build-essential software-properties-common curl git vim tree -# COPY --from=build /usr/local/cargo/bin/imager /bin/imager +# SETUP +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get -y install build-essential software-properties-common curl git vim tree +COPY --from=build /usr/local/cargo/bin/imager /bin/imager +COPY --from=build /usr/local/cargo/bin/imager-server /bin/imager-server # SECURITY & SANITY CHECK -# RUN sha1sum dist/native/libimager_nodejs.linux.node > dist/native/libimager_nodejs.linux.node.sha1 +RUN sha1sum /bin/imager > /bin/imager.sha1 +RUN sha1sum /bin/imager-server > /bin/imager-server.sha1 diff --git a/bin/scripts/build-release.sh b/bin/scripts/build-release.sh index 03d0f0d..ff77f47 100755 --- a/bin/scripts/build-release.sh +++ b/bin/scripts/build-release.sh @@ -1,4 +1,35 @@ # NOTE: Assumes the host is a mac (since we need to build mac binaries too). set -e -mkdir -p release \ No newline at end of file +# CHECK COMMIT +# GIT_RESULT=$(git status --porcelain) +# if [[ "$GIT_RESULT" != "" ]] +# then +# echo "changed files needing to be committed" +# exit 1 +# fi + +# BUILD LINUX +# ./scripts/docker/build.sh + +# BUILD MACOS +mkdir -p release/macos +cargo install --force --root release/macos --path imager-cli +cargo install --force --root release/macos --path imager-server +rm release/macos/.crates.toml + +# CHECKS - LINUX +test -f release/linux/bin/imager || (echo "FAILED!"; exit 1) +test -f release/linux/bin/imager.sha1 || (echo "FAILED!"; exit 1) +test -f release/linux/bin/imager-server || (echo "FAILED!"; exit 1) +test -f release/linux/bin/imager-server.sha1 || (echo "FAILED!"; exit 1) + +# CHECKS - MACOS +test -f release/macos/bin/imager || (echo "FAILED!"; exit 1) +test -f release/macos/bin/imager-server || (echo "FAILED!"; exit 1) + +# TEST +# npm test + +# PUBLISH +# npm publish \ No newline at end of file diff --git a/bin/scripts/docker/build.sh b/bin/scripts/docker/build.sh index 427b633..f1274b6 100755 --- a/bin/scripts/docker/build.sh +++ b/bin/scripts/docker/build.sh @@ -4,12 +4,10 @@ set -e docker build --tag=imager-bins:latest . # COPY - SETUP -# DOCKER_CP_CODE='tar --to-stdout -C dist/native --create libimager_nodejs.linux.node libimager_nodejs.linux.node.sha1' +mkdir -p release/linux/bin +DOCKER_CP_CODE='tar --to-stdout -C /bin --create imager imager-server imager.sha1 imager-server.sha1' # COPY TO DIST & LIB -# docker run --rm imager-rs:latest /bin/sh -c "$DOCKER_CP_CODE" | tar -x -C dist/native -# docker run --rm imager-rs:latest /bin/sh -c "$DOCKER_CP_CODE" | tar -x -C lib/native +docker run --rm imager-bins:latest /bin/sh -c "$DOCKER_CP_CODE" | tar -x -C release/linux/bin -# CLEANUP -# rm lib/native/libimager_nodejs.linux.node.sha1