forked from 0xsequence/ethgas-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.webapp
70 lines (59 loc) · 1.24 KB
/
Dockerfile.webapp
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
#
# Builder pre-image
#
FROM node:12-buster as builder
# Setup node
RUN apt-get update && \
apt-get install -y \
ca-certificates \
curl \
gcc \
git \
libc6-dev \
libcairo-dev \
libjpeg62-turbo-dev \
libpango1.0-dev \
libpixman-1-dev \
libusb-dev \
python \
ssh-client \
unzip \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# install lerna
RUN npm config set unsafe-perm true && \
npm install -g lerna && \
npm config set unsafe-perm false
COPY ./webapp /build
WORKDIR /build
RUN yarn install && yarn dist
#
# Dist image
#
FROM nginx:stable-alpine
COPY --from=builder /build/dist /usr/share/nginx/html
COPY --from=builder /build/config/*.json /etc/
RUN echo $'#!/bin/sh\n\
\n\
if [[ -z "$DIST" ]]; then\n\
export DIST=dist;\n\
fi\n\
\n\
APP_CONFIG=`cat /etc/webapp.${DIST}.json | tr "\n" " "`\n\
\n\
if [[ -z "${APP_CONFIG}" ]]; then\n\
echo "config file is empty, exiting.."\n\
exit 0\n\
fi\n\
\n\
sed -i \'s|\/\*APP_CONFIG>>\*\/{}\/\*<<APP_CONFIG\*\/|\'"$APP_CONFIG"\'|g\' /usr/share/nginx/html/index.html\n\
\n\
if [[ -z "$@" ]]; then\n\
/usr/sbin/nginx -g "daemon off;"\n\
else\n\
exec "$@"\n\
fi\n\
'\ > /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]