forked from TNOCS/c2app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (51 loc) · 1.59 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
# Creates the Chemical Hazard Tool server and GUI
#
# You can access the container using:
# docker run -it c2app sh
# To start it stand-alone:
# docker run -it -p 3000:3000 c2app
# Build the app separately
FROM node:14.17.2-alpine3.13 as builder
ARG SERVER_URL
ARG SERVER_PATH
ENV SERVER_URL=${SERVER_URL}
ENV SERVER_PATH=${SERVER_PATH}
RUN apk add --no-cache --virtual .gyp python3 make g++ git vips-dev && \
npm i -g yalc
RUN mkdir /packages && \
mkdir /packages/shared && \
mkdir /packages/gui && \
mkdir /packages/server
COPY ./packages/shared /packages/shared
WORKDIR /packages/shared
RUN npm install && \
npm run build:domain && \
yalc publish --private
COPY ./packages/server /packages/server
WORKDIR /packages/server
RUN yalc add c2app-models-utils && \
npm install && \
npm run build:domain
COPY ./packages/gui /packages/gui
WORKDIR /packages/gui
RUN rm -fr node_modules && \
yalc add c2app-models-utils && \
npm install && \
npm run build:domain
# Serve the built app
FROM node:14.17.2-alpine3.13 as app
ARG SERVER_URL
ARG SERVER_PATH
ENV SERVER_URL=${SERVER_URL}
ENV SERVER_PATH=${SERVER_PATH}
RUN mkdir -p /app
COPY --from=builder /packages/shared/node_modules /shared/node_modules
COPY --from=builder /packages/shared/dist /shared
COPY --from=builder /packages/server/node_modules /app/node_modules
COPY --from=builder /packages/server/package.json /app/package.json
COPY --from=builder /packages/server/dist /app/dist
COPY --from=builder /packages/server/.yalc /app/.yalc
COPY --from=builder /packages/gui/dist /app/public
WORKDIR /app
EXPOSE 3000
CMD ["node", "./dist/index.js"]