forked from overture-stack/arranger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
124 lines (95 loc) · 3.22 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#######################################################
# Builder
#######################################################
FROM node:13.13.0-alpine as builder
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_HOME=/app
ENV APP_USER=node
RUN apk --no-cache add shadow
RUN apk --no-cache add shadow \
&& groupmod -g $APP_GID $APP_USER \
&& usermod -u $APP_UID -g $APP_GID $APP_USER \
&& mkdir -p $APP_HOME \
&& chown -R $APP_USER $APP_HOME
WORKDIR $APP_HOME
COPY . .
RUN npm ci \
&& npm config set unsafe-perm true \
&& npm run bootstrap
#######################################################
# Arranger Server
#######################################################
FROM builder as server
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_HOME=/app
ENV APP_USER=node
WORKDIR $APP_HOME
USER $APP_USER
EXPOSE 5050
CMD ["npm", "run", "run-prod-server"]
#######################################################
# Builder 2
#######################################################
FROM builder as builder2
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_HOME=/app
ENV APP_USER=node
WORKDIR $APP_HOME
RUN cd modules/admin-ui \
&& npm run build
RUN cp -r modules/admin-ui/build ./arranger-admin
#######################################################
# Arranger Admin UI
#######################################################
FROM nginx:1.17.9-alpine as ui
ENV APP_UID=1000
ENV APP_GID=1000
ENV APP_USER=node
ENV APP_HOME=/app
ENV PORT=3000
ENV REACT_APP_BASE_URL=${REACT_APP_BASE_URL:-''}
ENV NGINX_PATH=${NGINX_PATH:-/etc/nginx}
COPY docker/ui/. $NGINX_PATH/.
RUN addgroup -S -g $APP_GID $APP_USER \
&& adduser -S -u $APP_UID -G $APP_USER $APP_USER \
&& chown -R $APP_UID:$APP_GID /etc/nginx/ \
&& chown -R $APP_UID:$APP_GID /var/cache \
&& chown -R $APP_UID:$APP_GID /var/log/nginx \
&& chown -R $APP_UID:$APP_GID /run \
&& mkdir -p $APP_HOME \
&& chown -R $APP_UID:$APP_GID $APP_HOME \
&& rm -rf /var/cache/apk/*
## this is throwaway code
# hardwired folder name for k8s writable path, while we change the K8s helm charts to take a config map
# creates a link to a yet inexistent file, which will be either fullfilled by entrypoint, or replaced by it.
RUN if [ $(expr $HOSTNAME : k8s) != 0 ]; then \
ln -s /custom-nginx/env-config.js $NGINX_PATH/env-config.js; \
fi
## end of throwaway code ^^^
COPY --from=builder2 /app $APP_HOME
RUN chown -R $APP_UID:$APP_GID $APP_HOME/arranger-admin \
&& ln -s $NGINX_PATH/env-config.js $APP_HOME/arranger-admin/env-config.js
WORKDIR $APP_HOME
USER $APP_USER
CMD ["/bin/sh", "/etc/nginx/server.sh"]
#######################################################
# Test
#######################################################
FROM node:13.13.0 as test
WORKDIR /app
# installs and starts elasticsearch
RUN apt-get update \
&& apt-get -y upgrade \
&& wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add - \
&& apt-get install -y apt-transport-https \
&& echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list \
&& apt-get update \
&& apt-get install elasticsearch=7.6.0
# initializes arranger
COPY --from=builder /app ./
CMD service elasticsearch start \
&& sh docker/test/wait-for-es.sh http://localhost:9200 npm run test \
&& service elasticsearch stop