1
- FROM nginx:1.24
2
-
3
-
4
- RUN apt-get update
5
- RUN apt-get install -y curl bash
6
-
7
-
8
- RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
9
- RUN apt-get install -y nodejs
1
+ FROM node:18-alpine as build
10
2
11
- RUN apt-get update && apt-get -y install git python g++ make
12
- RUN npm install --global yarn
3
+ RUN apk add --no-cache git
13
4
14
5
ENV WORKING_DIR=/tmp/cap
15
- ENV NGINX_HTML_DIR=/usr/share/nginx/html
16
- ENV NODE_OPTIONS="--max-old-space-size=8192"
17
-
18
- RUN mkdir -p $NGINX_HTML_DIR
19
-
20
- # We invalidate cache always because there is no easy way for now to detect
21
- # if something in the whole git repo changed. For docker git clone <url> <dir>
22
- # is always the same so it caches it.
23
- ARG CACHE_DATE=$(date)
24
-
25
- # get the code at a specific commit
26
- RUN git clone https://github.com/cernanalysispreservation/analysispreservation.cern.ch.git $WORKING_DIR/
27
-
28
- WORKDIR $WORKING_DIR/
29
6
30
- ARG BRANCH_NAME
31
-
32
- RUN echo $BRANCH_NAME
33
-
34
- RUN git fetch --all
35
-
36
- RUN if [ ! -z $BRANCH_NAME ]; then \
37
- # run commands to checkout a branch
38
- echo "Checkout branch $BRANCH_NAME" && \
39
- git checkout $BRANCH_NAME && \
40
- git pull origin $BRANCH_NAME; \
41
- fi
42
-
43
- RUN git log -10 --pretty=oneline --decorate
44
-
45
- RUN cp -rfp $WORKING_DIR/docker/nginx/nginx.conf /etc/nginx/nginx.conf
46
-
47
- WORKDIR $WORKING_DIR/ui
7
+ WORKDIR $WORKING_DIR
48
8
49
9
ARG PIWIK_ENV=dev
50
10
ARG ENABLE_E2E
@@ -61,74 +21,68 @@ ARG PIWIK_SITEID_PROD
61
21
ARG PIWIK_SITEID_QA
62
22
ARG PIWIK_SITEID_TEST
63
23
64
- RUN echo "" >> $WORKING_DIR/ui/cap-react/.env
65
- RUN echo "" >> $WORKING_DIR/ui/cap-react/.env
66
- RUN echo "PIWIK_URL=$CAP_PIWIK_URL" >> $WORKING_DIR/ui/cap-react/.env
67
- RUN echo "ENABLE_E2E=$ENABLE_E2E" >> $WORKING_DIR/ui/cap-react/.env
68
-
69
- RUN rm /bin/sh && ln -s /bin/bash /bin/sh
24
+ RUN mkdir -p ui/cap-react
25
+ RUN echo "PIWIK_URL=$CAP_PIWIK_URL" >> ui/cap-react/.env
26
+ RUN echo "ENABLE_E2E=$ENABLE_E2E" >> ui/cap-react/.env
70
27
71
28
RUN if [[ $PIWIK_ENV == "dev" ]]; then \
72
- echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_DEV" >> $WORKING_DIR/ ui/cap-react/.env; \
29
+ echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_DEV" >> ui/cap-react/.env; \
73
30
fi
74
31
75
32
RUN if [[ $PIWIK_ENV == "prod" ]]; then \
76
- echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_PROD" >> $WORKING_DIR/ ui/cap-react/.env; \
33
+ echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_PROD" >> ui/cap-react/.env; \
77
34
fi
78
35
79
36
RUN if [[ $PIWIK_ENV == "qa" ]]; then \
80
- echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_QA" >> $WORKING_DIR/ ui/cap-react/.env; \
37
+ echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_QA" >> ui/cap-react/.env; \
81
38
fi
82
39
83
40
RUN if [[ $PIWIK_ENV == "test" ]]; then \
84
- echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_TEST" >> $WORKING_DIR/ ui/cap-react/.env; \
41
+ echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_TEST" >> ui/cap-react/.env; \
85
42
fi
86
43
44
+
87
45
RUN echo "=========================="
88
46
RUN echo $CAP_PIWIK_SITEID_TEST
89
47
RUN echo $PIWIK_SITEID_TEST
90
48
RUN echo "=========================="
91
- RUN less $WORKING_DIR/ ui/cap-react/.env
49
+ RUN cat ui/cap-react/.env
92
50
RUN echo "=========================="
93
51
94
- RUN yarn config set cache ~/.my-yarn-cache-dir
52
+ WORKDIR $WORKING_DIR/ui
95
53
96
- RUN pwd
54
+ # build CAP UI
55
+ COPY ./ui ${WORKING_DIR}/ui
97
56
RUN yarn install
98
- # RUN yarn upgrade
99
-
100
57
RUN yarn workspace cap-react build
101
- RUN pwd
102
- RUN ls ./cap-react/dist/*
103
- RUN cp -rfp ./cap-react/dist/* $NGINX_HTML_DIR
104
58
105
- # build docs general
59
+ # build general docs
60
+ COPY ./docs ${WORKING_DIR}/docs
106
61
WORKDIR $WORKING_DIR/docs
107
-
108
- RUN yarn
62
+ RUN yarn install
109
63
RUN yarn build
110
64
111
- RUN mkdir -p $NGINX_HTML_DIR/docs/general
112
- RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general
113
-
114
-
115
- # build docs API
65
+ # build API docs
116
66
RUN git clone https://github.com/cernanalysispreservation/cap-api-docs.git $WORKING_DIR/cap-api-docs/
117
67
WORKDIR $WORKING_DIR/cap-api-docs
118
-
119
- RUN npm install
68
+ RUN npm install --maxsockets 1
120
69
RUN npm run build
121
70
122
- RUN mkdir -p $NGINX_HTML_DIR/docs/api
123
- RUN cp -rfp ./web_deploy/* $NGINX_HTML_DIR/docs/api
124
-
125
-
126
- # build docs client
71
+ # build client docs
127
72
RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/
128
73
WORKDIR $WORKING_DIR/cap-client/docs
129
-
130
- RUN yarn
74
+ RUN yarn install
131
75
RUN yarn build
132
76
133
- RUN mkdir -p $NGINX_HTML_DIR/docs/client
134
- RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/client
77
+
78
+ FROM nginx:1.24
79
+
80
+ ENV WORKING_DIR=/tmp/cap
81
+ ENV NGINX_HTML_DIR=/usr/share/nginx/html/
82
+ RUN mkdir -p $NGINX_HTML_DIR
83
+
84
+ COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
85
+ COPY --from=build ${WORKING_DIR}/ui/cap-react/dist/ $NGINX_HTML_DIR
86
+ COPY --from=build ${WORKING_DIR}/docs/_book/ $NGINX_HTML_DIR/docs/general
87
+ COPY --from=build ${WORKING_DIR}/cap-api-docs/web_deploy/ $NGINX_HTML_DIR/docs/api
88
+ COPY --from=build ${WORKING_DIR}/cap-client/docs/_book/ $NGINX_HTML_DIR/docs/client
0 commit comments