Dockerfile.my 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. iputils-ping net-tools screen chromium-browser \
  39. && apt autoclean -y \
  40. && apt autoremove -y \
  41. && rm -rf /var/lib/apt/lists/*
  42. # Additional packages require ~600MB
  43. # libreoffice pinta language-pack-zh-hant language-pack-gnome-zh-hant firefox-locale-zh-hant libreoffice-l10n-zh-tw
  44. # tini to fix subreap
  45. ARG TINI_VERSION=v0.18.0
  46. ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /bin/tini
  47. RUN chmod +x /bin/tini
  48. # ffmpeg
  49. RUN apt update \
  50. && apt install -y --no-install-recommends --allow-unauthenticated \
  51. ffmpeg \
  52. && rm -rf /var/lib/apt/lists/* \
  53. && mkdir /usr/local/ffmpeg \
  54. && ln -s /usr/bin/ffmpeg /usr/local/ffmpeg/ffmpeg
  55. # python library
  56. COPY rootfs/usr/local/lib/web/backend/requirements.txt /tmp/
  57. RUN apt-get update \
  58. && dpkg-query -W -f='${Package}\n' > /tmp/a.txt \
  59. && apt-get install -y python3-pip python3-dev build-essential \
  60. && pip3 install setuptools wheel && pip3 install -r /tmp/requirements.txt \
  61. && ln -s /usr/bin/python3 /usr/local/bin/python \
  62. && dpkg-query -W -f='${Package}\n' > /tmp/b.txt \
  63. && apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \
  64. && apt-get autoclean -y \
  65. && apt-get autoremove -y \
  66. && rm -rf /var/lib/apt/lists/* \
  67. && rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt
  68. RUN apt update && apt-get install -y snapd squashfuse fuse
  69. RUN systemctl enable snapd
  70. #CMD [ "/sbin/init" ]
  71. #RUN snap install chromium
  72. ################################################################################
  73. # builder
  74. ################################################################################
  75. FROM ubuntu:20.04 as builder
  76. RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list;
  77. RUN apt-get update \
  78. && apt-get install -y --no-install-recommends curl ca-certificates gnupg patch
  79. # nodejs
  80. RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
  81. && apt-get install -y nodejs
  82. # yarn
  83. RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
  84. && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
  85. && apt-get update \
  86. && apt-get install -y yarn
  87. # build frontend
  88. COPY web /src/web
  89. RUN cd /src/web \
  90. && yarn \
  91. && yarn build
  92. RUN sed -i 's#app/locale/#novnc/app/locale/#' /src/web/dist/static/novnc/app/ui.js
  93. ################################################################################
  94. # merge
  95. ################################################################################
  96. FROM system
  97. LABEL maintainer="fcwu.tw@gmail.com"
  98. COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
  99. COPY rootfs /
  100. RUN ln -sf /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify && \
  101. chmod +x /usr/local/lib/web/frontend/static/websockify/run
  102. EXPOSE 80
  103. WORKDIR /root
  104. ENV HOME=/home/ubuntu \
  105. SHELL=/bin/bash
  106. HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
  107. ENTRYPOINT ["/startup.sh"]