forked from justadudewhohacks/opencv4nodejs
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Dockerfile.alpine.examples
41 lines (39 loc) · 1.59 KB
/
Dockerfile.alpine.examples
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
# ALPINE Version is currently not working.
# docker build --build-arg VERSION=1.0.0 -t test-alpine -f Dockerfile.alpine.examples .
# docker run --rm test-alpine
# docker run -it --rm test test-alpine
##############
# First step transpile Typescript to JS files with NODE_ENV=development
FROM urielch/opencv-nodejs:6.2.5-alpine As build
WORKDIR /usr/src/app
ENV NODE_ENV=development
RUN npm install -g [email protected]
COPY examples/package.json ./
COPY examples/tsconfig.prod.json ./tsconfig.json
RUN sed -i -r "s/\"@u4\/opencv4nodejs\": \"link:..\",//g" package.json
RUN npm install && npm cache clean --force
RUN npm link @u4/opencv4nodejs
COPY examples/src/applyColorMap.ts examples/src/utils.ts ./src/
# do not need data at transpile step
# COPY ./data/Lenna.png /usr/src/data/Lenna.png
RUN npx tsc
##############
# Second step Build finAal image and clean node_nodules content this time NODE_ENV=production
FROM urielch/opencv-nodejs:6.2.5-alpine
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY --from=build /usr/src/app/package*.json ./
RUN npm install -g [email protected] && \
npm install && \
rimraf node_modules/**/*.{md,ts,map,h,c,cc,cpp,gyp,yml,txt} node_modules/**/{LICENSE,.github,.npmignore,LICENSE.txt,.travis.yml,.eslintrc,sponsors} && \
npm uninstall -g [email protected] && \
npm cache clean --force && \
find . -type f -empty -print -delete && \
find . -type d -empty -print -delete && \
npm link @u4/opencv4nodejs
COPY ./data/Lenna.png /usr/src/data/Lenna.png
COPY --from=build /usr/src/app/src/*.js ./src/
# ARG VERSION
# ENV VERSION=$VERSION
ENV HEADLESS=1
CMD ["node", "src/applyColorMap"]