-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
110 lines (110 loc) · 3.17 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
ARG PROFILE=production
#
# target:android
FROM ubuntu:latest AS android
ARG PROFILE
ARG SDK_FILE=commandlinetools-linux-7583922_latest.zip
COPY / /src
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV NODE_ENV=$PROFILE
RUN \
#
# packages
apt-get --yes update && \
apt-get --yes install --no-install-recommends ${PKG_DEV:= \
gradle \
inotify-tools \
openjdk-8-jdk-headless \
} && \
apt-get --yes install --no-install-recommends ${PKG_TMP:= \
gnupg \
wget \
} && \
#
# buildenv
. /etc/lsb-release && \
#
# nodejs
wget --output-document=- https://deb.nodesource.com/gpgkey/nodesource.gpg.key \
| apt-key add - && \
echo "deb https://deb.nodesource.com/node_12.x $DISTRIB_CODENAME main" \
>/etc/apt/sources.list.d/nodejs.list && \
apt-get --yes update && \
apt-get --yes install --no-install-recommends \
nodejs && \
#
# npm@6 (https://github.com/apache/cordova-lib/issues/859)
npm install --global npm@6 && \
export PATH=$PATH && \
#
# android-sdk
cd $(mktemp --directory) && \
wget https://dl.google.com/android/repository/$SDK_FILE && \
mkdir --parent $ANDROID_SDK_ROOT && \
unzip -d $ANDROID_SDK_ROOT $SDK_FILE && \
yes | $ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
--licenses >/dev/null && \
$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
'build-tools;30.0.3' && \
#
# wooportal
test "$PROFILE" = 'production' && ( \
npm --prefix /src install --also=development && \
npm --prefix /src run build @wooportal/client:browser:production && \
npm --prefix /src run cordova platform add [email protected] && \
npm --prefix /src run cordova build android -- --release && \
mv $(find /src -name app-release.apk) /client.apk && \
find $ANDROID_SDK_ROOT /root /src -delete -mindepth 1 && \
apt-get --yes purge --autoremove $PKG_DEV \
) || ( \
mkdir /src/www && \
npm --prefix /src install cordova && \
npm --prefix /src run cordova platform add [email protected] && \
npm --prefix /src run cordova compile android \
) && \
#
# cleanup
apt-get --yes clean all && \
apt-get --yes purge --autoremove $PKG_TMP && \
find /tmp /var/lib/apt/lists -delete -mindepth 1
#
# target
FROM alpine:latest
ARG PROFILE
COPY / /src
COPY --from=android /client.apk /client.apk
ENV NODE_ENV=$PROFILE
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN \
#
# packages
apk --no-cache add \
nodejs && \
apk --no-cache --virtual build add \
npm && \
#
# npm@6 (https://github.com/apache/cordova-lib/issues/859)
npm install --global npm@6 && \
export PATH=$PATH && \
#
# wooportal
npm --prefix /src install --also=development && \
npm --prefix /src run build @wooportal/client:browser:production && \
npm --prefix /src run cordova platform add [email protected] && \
npm --prefix /src run cordova build browser -- --release && \
npm --prefix /src run build @wooportal/client:server:production && \
npm --prefix /src run ngsw platforms/browser/www ngsw-config.json && \
npm --prefix /src clean-install --no-optional --only=production && \
mv /client.apk /src/platforms/browser/www && \
#
# cleanup
apk del --purge build && \
find /root /tmp -delete -mindepth 1
#
# runtime
EXPOSE 4000
WORKDIR /src
HEALTHCHECK CMD wget -q --spider 127.0.0.1:4000/imprint
CMD node platforms/server/main