Skip to content

Commit

Permalink
imager bin pre-release setup
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyn committed Nov 17, 2019
1 parent 75b8e82 commit 04765a7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 34 deletions.
3 changes: 3 additions & 0 deletions bin/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
**/assets/output/
**/assets/samples/
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release/
54 changes: 26 additions & 28 deletions bin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,49 @@
###############################################################################
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
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
33 changes: 32 additions & 1 deletion bin/scripts/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# NOTE: Assumes the host is a mac (since we need to build mac binaries too).
set -e

mkdir -p release
# 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
8 changes: 3 additions & 5 deletions bin/scripts/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 04765a7

Please sign in to comment.