|
| 1 | +# Built with arch: arm64 flavor: lxde image: ubuntu:18.04 |
| 2 | +# |
| 3 | +################################################################################ |
| 4 | +# base system |
| 5 | +################################################################################ |
| 6 | + |
| 7 | +# qemu helper for arm build |
| 8 | +FROM ubuntu:18.04 as amd64 |
| 9 | +RUN apt update && apt install -y qemu-user-static |
| 10 | +FROM arm64v8/ubuntu:18.04 as system |
| 11 | +COPY --from=amd64 /usr/bin/qemu-aarch64-static /usr/bin/ |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list; |
| 16 | + |
| 17 | + |
| 18 | +# built-in packages |
| 19 | +ENV DEBIAN_FRONTEND noninteractive |
| 20 | +RUN apt update \ |
| 21 | + && apt install -y --no-install-recommends software-properties-common curl apache2-utils \ |
| 22 | + && apt update \ |
| 23 | + && apt install -y --no-install-recommends --allow-unauthenticated \ |
| 24 | + supervisor nginx sudo net-tools zenity xz-utils \ |
| 25 | + dbus-x11 x11-utils alsa-utils \ |
| 26 | + mesa-utils libgl1-mesa-dri \ |
| 27 | + && apt autoclean -y \ |
| 28 | + && apt autoremove -y \ |
| 29 | + && rm -rf /var/lib/apt/lists/* |
| 30 | +# install debs error if combine together |
| 31 | +RUN add-apt-repository -y ppa:fcwu-tw/apps \ |
| 32 | + && apt update \ |
| 33 | + && apt install -y --no-install-recommends --allow-unauthenticated \ |
| 34 | + xvfb x11vnc=0.9.13-3 x11vnc-data=0.9.13-3 \ |
| 35 | + vim-tiny firefox chromium-browser ttf-ubuntu-font-family ttf-wqy-zenhei \ |
| 36 | + && add-apt-repository -r ppa:fcwu-tw/apps \ |
| 37 | + && apt autoclean -y \ |
| 38 | + && apt autoremove -y \ |
| 39 | + && rm -rf /var/lib/apt/lists/* |
| 40 | + |
| 41 | +RUN apt update \ |
| 42 | + && apt install -y --no-install-recommends --allow-unauthenticated \ |
| 43 | + lxde gtk2-engines-murrine gnome-themes-standard gtk2-engines-pixbuf gtk2-engines-murrine arc-theme \ |
| 44 | + && apt autoclean -y \ |
| 45 | + && apt autoremove -y \ |
| 46 | + && rm -rf /var/lib/apt/lists/* |
| 47 | + |
| 48 | + |
| 49 | +# Additional packages require ~600MB |
| 50 | +# libreoffice pinta language-pack-zh-hant language-pack-gnome-zh-hant firefox-locale-zh-hant libreoffice-l10n-zh-tw |
| 51 | + |
| 52 | +# tini for subreap |
| 53 | +ARG TINI_VERSION=v0.18.0 |
| 54 | +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-arm64 /bin/tini |
| 55 | +RUN chmod +x /bin/tini |
| 56 | + |
| 57 | +# ffmpeg |
| 58 | +RUN mkdir -p /usr/local/ffmpeg \ |
| 59 | + && curl -sSL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | tar xJvf - -C /usr/local/ffmpeg/ --strip 1 |
| 60 | + |
| 61 | +# python library |
| 62 | +COPY rootfs/usr/local/lib/web/backend/requirements.txt /tmp/ |
| 63 | +RUN apt-get update \ |
| 64 | + && dpkg-query -W -f='${Package}\n' > /tmp/a.txt \ |
| 65 | + && apt-get install -y python-pip python-dev build-essential \ |
| 66 | +&& pip install setuptools wheel && pip install -r /tmp/requirements.txt \ |
| 67 | + && dpkg-query -W -f='${Package}\n' > /tmp/b.txt \ |
| 68 | + && apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \ |
| 69 | + && apt-get autoclean -y \ |
| 70 | + && apt-get autoremove -y \ |
| 71 | + && rm -rf /var/lib/apt/lists/* \ |
| 72 | + && rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt |
| 73 | + |
| 74 | + |
| 75 | +################################################################################ |
| 76 | +# builder |
| 77 | +################################################################################ |
| 78 | +FROM ubuntu:18.04 as builder |
| 79 | + |
| 80 | + |
| 81 | +RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list; |
| 82 | + |
| 83 | + |
| 84 | +RUN apt-get update \ |
| 85 | + && apt-get install -y --no-install-recommends curl ca-certificates gnupg patch |
| 86 | + |
| 87 | +# nodejs |
| 88 | +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \ |
| 89 | + && apt-get install -y nodejs |
| 90 | + |
| 91 | +# yarn |
| 92 | +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ |
| 93 | + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ |
| 94 | + && apt-get update \ |
| 95 | + && apt-get install -y yarn |
| 96 | + |
| 97 | +# build frontend |
| 98 | +COPY web /src/web |
| 99 | +RUN cd /src/web \ |
| 100 | + && yarn \ |
| 101 | + && npm run build |
| 102 | + |
| 103 | + |
| 104 | +RUN cd /src/web/dist/static/novnc && patch -p0 < /src/web/novnc-armhf-1.patch |
| 105 | + |
| 106 | + |
| 107 | +################################################################################ |
| 108 | +# merge |
| 109 | +################################################################################ |
| 110 | +FROM system |
| 111 | +LABEL maintainer="fcwu.tw@gmail.com" |
| 112 | + |
| 113 | +COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/ |
| 114 | +COPY rootfs / |
| 115 | +RUN ln -sf /usr/local/lib/web/frontend/static/websockify" "/usr/local/lib/web/frontend/static/novnc/utils/websockify && chmod +x /usr/local/lib/web/frontend/static/websockify/run |
| 116 | +RUN ln -sf /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify && \ |
| 117 | +chmod +x /usr/local/lib/web/frontend/static/websockify/run |
| 118 | + |
| 119 | +EXPOSE 80 |
| 120 | +WORKDIR /root |
| 121 | +ENV HOME=/home/ubuntu \ |
| 122 | + SHELL=/bin/bash |
| 123 | +HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health |
| 124 | +ENTRYPOINT ["/startup.sh"] |
0 commit comments