Dockerfile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. FROM seleniarm/node-chromium
  2. ARG G4F_VERSION
  3. ARG G4F_USER=g4f
  4. ARG G4F_USER_ID=1000
  5. ARG G4F_NO_GUI
  6. ARG G4F_PASS=secret
  7. ENV G4F_VERSION $G4F_VERSION
  8. ENV G4F_USER $G4F_USER
  9. ENV G4F_USER_ID $G4F_USER_ID
  10. ENV G4F_NO_GUI $G4F_NO_GUI
  11. ENV SE_SCREEN_WIDTH 1850
  12. ENV PYTHONUNBUFFERED 1
  13. ENV G4F_DIR /app
  14. ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=$G4F_PASS
  15. ENV HOME /home/$G4F_USER
  16. ENV PATH $PATH:$HOME/.local/bin
  17. ENV SE_DOWNLOAD_DIR $HOME/Downloads
  18. ENV SEL_USER $G4F_USER
  19. ENV SEL_UID $G4F_USER_ID
  20. ENV SEL_GID $G4F_USER_ID
  21. USER root
  22. # If docker compose, install git
  23. RUN if [ "$G4F_VERSION" = "" ] ; then \
  24. apt-get -qqy update && \
  25. apt-get -qqy install git \
  26. ; fi
  27. # Install Python3, pip, remove OpenJDK 11, clean up
  28. RUN apt-get -qqy update \
  29. && apt-get -qqy install python3 python-is-python3 pip \
  30. && apt-get -qyy remove openjdk-11-jre-headless \
  31. && apt-get -qyy autoremove \
  32. && apt-get -qyy clean \
  33. && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
  34. # Update entrypoint
  35. COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
  36. COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
  37. COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
  38. # If no gui
  39. RUN if [ "$G4F_NO_GUI" ] ; then \
  40. rm /etc/supervisor/conf.d/gui.conf \
  41. ; fi
  42. # Change background image
  43. COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
  44. # Add user, fix permissions
  45. RUN groupadd -g $G4F_USER_ID $G4F_USER \
  46. && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
  47. && echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
  48. && mkdir "${SE_DOWNLOAD_DIR}" \
  49. && chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
  50. && chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
  51. # Switch user
  52. USER $G4F_USER_ID
  53. # Set VNC password
  54. RUN mkdir -p ${HOME}/.vnc \
  55. && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
  56. # Set the working directory in the container.
  57. WORKDIR $G4F_DIR
  58. # Copy the project's requirements file into the container.
  59. COPY requirements.txt $G4F_DIR
  60. # Upgrade pip for the latest features and install the project's Python dependencies.
  61. RUN pip install --break-system-packages --upgrade pip \
  62. && pip install --break-system-packages -r requirements.txt \
  63. && pip install --break-system-packages \
  64. undetected-chromedriver selenium-wire \
  65. && pip uninstall -y --break-system-packages \
  66. pywebview plyer
  67. # Copy the entire package into the container.
  68. ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
  69. # Expose ports
  70. EXPOSE 8080 1337