-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
61 lines (45 loc) · 1.72 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
# Copyright Tecnalia Research & Innovation (https://www.tecnalia.com)
# Copyright Tecnalia Blockchain LAB
#
# SPDX-License-Identifier: Apache-2.0
FROM node:18.20.6 AS BUILD_IMAGE
# default values pf environment variables
# that are used inside container
ENV DEFAULT_WORKDIR /opt
ENV EXPLORER_APP_PATH $DEFAULT_WORKDIR/explorer
# set default working dir inside container
WORKDIR $EXPLORER_APP_PATH
COPY . .
# install required dependencies by NPM packages:
# current dependencies are: python, make, g++
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y build-essential g++
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
# install NPM dependencies
RUN npm install && npm run build && npm prune --production
# build explorer app
RUN cd client && npm install && npm prune --production && yarn build
# remove installed packages to free space
RUN /usr/local/bin/node-prune
RUN rm -rf node_modules/rxjs/src/
RUN rm -rf node_modules/rxjs/bundles/
RUN rm -rf node_modules/rxjs/_esm5/
RUN rm -rf node_modules/rxjs/_esm2015/
RUN rm -rf node_modules/grpc/deps/grpc/third_party/
FROM node:18.20.6
# database configuration
ENV DATABASE_HOST 127.0.0.1
ENV DATABASE_PORT 5432
ENV DATABASE_NAME fabricexplorer
ENV DATABASE_USERNAME hppoc
ENV DATABASE_PASSWD password
ENV EXPLORER_APP_ROOT app
ENV DEFAULT_WORKDIR /opt
ENV EXPLORER_APP_PATH $DEFAULT_WORKDIR/explorer
WORKDIR $EXPLORER_APP_PATH
COPY . .
COPY --from=BUILD_IMAGE $EXPLORER_APP_PATH/dist ./app/
COPY --from=BUILD_IMAGE $EXPLORER_APP_PATH/client/build ./client/build/
COPY --from=BUILD_IMAGE $EXPLORER_APP_PATH/node_modules ./node_modules/
# run blockchain explorer main app
CMD npm run app-start && tail -f /dev/null