-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (64 loc) · 2.23 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
###############################################################################
# RUST (NATIVE) BUILD
###############################################################################
FROM rust:latest as build-rust
# SYSTEM DEPENDENCIES
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
# SETUP
WORKDIR /code/
# PROJECT - SPECIAL
ADD .cargo .cargo
# PROJECT DEPENDENCIES
RUN apt-get install -y openssl pkg-config libssl-dev && apt-get clean
RUN mkdir -p src
RUN echo '' > ./src/lib.rs
ADD ./Cargo.toml .
RUN cargo build --release
# PROJECT ASSETS
ADD ./assets/test ./assets/test
# PROJECT APPLICATION
RUN rm ./target/release/deps/libimager_nodejs* && \
rm ./target/release/deps/imager_nodejs* && \
rm ./target/release/libimager_nodejs*
ADD ./src/ ./src/
RUN cargo build --release
RUN mkdir -p dist/native && \
cp target/release/libimager_nodejs.so dist/native/libimager_nodejs.linux.node
###############################################################################
# NODE ENVIRONMENT
###############################################################################
FROM ubuntu:18.04 as node-env
# 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
COPY --from=build-rust /code/dist/native/libimager_nodejs.linux.node ./dist/native/libimager_nodejs.linux.node
COPY --from=build-rust /code/dist/native/libimager_nodejs.linux.node ./lib/native/libimager_nodejs.linux.node
# SECURITY & SANITY CHECK
RUN sha1sum dist/native/libimager_nodejs.linux.node > dist/native/libimager_nodejs.linux.node.sha1
# PROJECT DEPENDENCIES
RUN apt-get -y install nodejs npm
# PROJECT - TOP-LEVEL FILES
ADD LICENSE .
ADD README.md .
ADD .babelrc .
ADD jest.config.js .
ADD package-lock.json .
ADD package.json .
ADD tsconfig.json .
# PROJECT - BUILD DEPENDENCIES
RUN npm install
# PROJECT - CODE & OTHER
ADD lib lib
ADD assets/test assets/test
ADD scripts/build-rust.sh scripts/build-rust.sh
# PROJECT - BUILD CODE
ENV PRE_BUILT_LIB_IMAGER_NODEJS=1
RUN npm run build
# PROJECT - TEST
RUN npm test