forked from biosimulations/biosimulations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
96 lines (80 loc) · 2.35 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#############
### base ###
#############
FROM node:16-alpine as base
#The name of the app to build
ARG app
ENV APP=$app
RUN echo building ${APP}
#############
### build ###
#############
FROM base as build
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install nrwl cli
RUN npm install -g @nrwl/cli
# install dependencies needed to compile canvas (needed for Vega-embed)
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache \
python3 \
pkgconfig \
pixman-dev \
cairo-dev \
pango-dev \
alpine-sdk \
cmake
RUN ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --no-cache-dir --upgrade pip setuptools
# copy dependencies
# Copy over dependency list
COPY tsconfig.base.json /app/tsconfig.base.json
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
COPY declarations.d.ts /app/declarations.d.ts
# set working directory
# install the app, including the dev dependencies
RUN npm ci
COPY nx.json /app/nx.json
COPY angular.json /app/angular.json
#copy source
COPY libs /app/libs
COPY apps /app/apps
# generate build
# Redifining the env *might* correct cache invalidation issue
ENV APP=${APP}
ENV node_options=--max_old_space_size=6144
RUN nx build ${APP} --prod --with-deps
############
### prod ###
############
# base image
FROM base as prod
WORKDIR /app
#Copy over dependency list
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
# install the app and include only dependencies needed to run
RUN npm ci --only=production --ignore-scripts=true
RUN apk add --no-cache --virtual .gyp python3 make g++\
pkgconfig \
pixman-dev \
cairo-dev \
pango-dev \
alpine-sdk \
cmake \
# remove sharp since it is currently installed and the install comand below wont actually run the post install script
# Therefore, the node module folder wont have the needed binaries
# Removing it here causes a fresh install which works properly
# This is problematic however, since there is no longer a version lock
# TODO find a way to ensure version
&& npm uninstall sharp \
&& npm install sharp --ignore-scripts=false \
&& apk del .gyp
# copy artifact build from the 'build environment'
RUN echo app is ${APP}
COPY --from=build /app/dist/apps/${APP}/ .
EXPOSE 3333
CMD node main.js