-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
74 lines (56 loc) · 2.69 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
FROM node:10.13.0 as build
WORKDIR /app
ARG SERVICE=demo
COPY core ./core
# COPY services ./services -- copy all services if needed
COPY services/${SERVICE} ./services/${SERVICE}
COPY package.json .
COPY package-lock.json .
COPY tsconfig.json .
RUN npm install -g [email protected]
RUN npm install
RUN cd ./services/${SERVICE} && npm install
COPY core/smf-core-docker.js ./node_modules/smf-core.js
ENV NODE_ENV=production
RUN npm run build-prod
##################################################################################################
FROM node:10.13.0-alpine as prod
ARG SERVICE=demo
ENV SERVICE=$SERVICE
##################################################################################################
WORKDIR /app
COPY package.json .
COPY package-lock.json .
# copy package.json & package-lock.json (if the latter exists)
COPY services/${SERVICE}/package*.json ./services/${SERVICE}/
COPY --from=build /app/build .
# ENV NODE_ENV=production NODE_PATH=/app PORT=80
ENV NODE_ENV=production NODE_PATH=/app
RUN npm install
RUN cd ./services/${SERVICE} && npm install
COPY core/smf-core-docker.js ./node_modules/smf-core.js
##################################################################################################
# (optional) copy service data
COPY docker-temp.txt ./services/${SERVICE}/data* /data/
# (optional) copy service libs
COPY docker-temp.txt ./services/${SERVICE}/library* /library/
##################################################################################################
# todo: move AI env vars to a service Dockerfile include, when implemented
ENV CONDA_DIR=/opt/conda
ENV PATH=$CONDA_DIR/bin:$PATH
##################################################################################################
# (optional) install service files
COPY docker-temp.txt ./services/${SERVICE}/install.sh* ./services/${SERVICE}/
# not sure why "-f..." doesn't work with "chmod" etc., use "if test..." instead
# RUN [ -f "./services/${SERVICE}/install.sh" ] && chmod +rx ./services/${SERVICE}/install.sh && ./services/${SERVICE}/install.sh
RUN if test -e "./services/${SERVICE}/install.sh"; then chmod +rx ./services/${SERVICE}/install.sh && ./services/${SERVICE}/install.sh ; fi
##################################################################################################
# copy sails web app, if exists
COPY docker-temp.txt ./services/${SERVICE}/web-sails* ./services/${SERVICE}/web-sails/
RUN [ -d "./services/${SERVICE}/web-sails" ] && cd ./services/${SERVICE}/web-sails && npm install
ENV SAILS_PATH=./web-sails
# EXPOSE 1337
##################################################################################################
COPY smf-stack.json .
ENV SMF_ROOT_PATH=../
CMD ["node", "./core/index.js"]