Dockerfile.amd64 4.6 KB

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