Dockerfile.j2 5.1 KB

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