1- FROM ubuntu:16.04
2- LABEL maintainer="fcwu.tw@gmail.com"
1+ # ###############################################################################
2+ # base system
3+ # ###############################################################################
4+ FROM ubuntu:16.04 as system
35
4- RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/apt/sources.list
6+ ARG localbuild
7+ RUN if [ "x$localbuild" != "x" ]; then sed -i 's#http://archive.ubuntu.com/#http://qnap.dorowu.com/#' /etc/apt/sources.list; fi
58
69# built-in packages
710RUN apt-get update \
811 && apt-get install -y --no-install-recommends software-properties-common curl apache2-utils \
912 && add-apt-repository ppa:fcwu-tw/apps \
1013 && apt-get update \
1114 && apt-get install -y --no-install-recommends --allow-unauthenticated \
12- supervisor \
13- sudo vim-tiny \
14- net-tools \
15- lxde x11vnc xvfb \
16- gtk2-engines-murrine ttf-ubuntu-font-family \
17- libreoffice firefox \
18- fonts-wqy-microhei \
19- language-pack-zh-hant language-pack-gnome-zh-hant firefox-locale-zh-hant libreoffice-l10n-zh-tw \
20- nginx \
21- python-pip python-dev build-essential \
15+ supervisor nginx sudo vim-tiny net-tools zenity xz-utils \
16+ dbus-x11 x11-utils alsa-utils \
2217 mesa-utils libgl1-mesa-dri \
23- gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine pinta arc-theme \
24- dbus-x11 x11-utils \
18+ lxde x11vnc xvfb \
19+ gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \
20+ firefox chromium-browser \
21+ ttf-ubuntu-font-family ttf-wqy-zenhei \
22+ && add-apt-repository -r ppa:fcwu-tw/apps \
2523 && apt-get autoclean \
2624 && apt-get autoremove \
2725 && rm -rf /var/lib/apt/lists/*
28-
26+ # Additional packages require ~600MB
27+ # libreoffice pinta language-pack-zh-hant language-pack-gnome-zh-hant firefox-locale-zh-hant libreoffice-l10n-zh-tw
2928
3029# tini for subreap
3130ARG TINI_VERSION=v0.9.0
@@ -36,9 +35,57 @@ RUN chmod +x /bin/tini
3635RUN mkdir -p /usr/local/ffmpeg \
3736 && curl -sSL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz | tar xJvf - -C /usr/local/ffmpeg/ --strip 1
3837
39- ADD image/usr/local/lib/web/backend/requirements.txt /tmp/
40- RUN pip install setuptools wheel && pip install -r /tmp/requirements.txt
41- ADD image /
38+ # python library
39+ COPY image/usr/local/lib/web/backend/requirements.txt /tmp/
40+ RUN apt-get update \
41+ && dpkg-query -W -f='${Package}\n ' > /tmp/a.txt \
42+ && apt-get install -y python-pip python-dev build-essential \
43+ && pip install setuptools wheel && pip install -r /tmp/requirements.txt \
44+ && dpkg-query -W -f='${Package}\n ' > /tmp/b.txt \
45+ && apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \
46+ && apt-get autoclean -y \
47+ && apt-get autoremove -y \
48+ && rm -rf /var/lib/apt/lists/* \
49+ && rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt
50+
51+
52+ # ###############################################################################
53+ # builder
54+ # ###############################################################################
55+ FROM ubuntu:16.04 as builder
56+
57+ ARG localbuild
58+ RUN if [ "x$localbuild" != "x" ]; then sed -i 's#http://archive.ubuntu.com/#http://qnap.dorowu.com/#' /etc/apt/sources.list; fi
59+
60+ RUN apt-get update \
61+ && apt-get install -y --no-install-recommends curl ca-certificates
62+
63+ # nodejs
64+ RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \
65+ && apt-get install -y nodejs
66+
67+ # yarn
68+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
69+ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
70+ && apt-get update \
71+ && apt-get install -y yarn
72+
73+ # build frontend
74+ COPY web /src/web
75+ RUN cd /src/web \
76+ && yarn \
77+ && npm run build
78+
79+
80+ # ###############################################################################
81+ # merge
82+ # ###############################################################################
83+ FROM scratch
84+ LABEL maintainer="fcwu.tw@gmail.com"
85+
86+ COPY --from=system / /
87+ COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
88+ COPY image /
4289
4390EXPOSE 80
4491WORKDIR /root
0 commit comments