Dockerfile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-gui.conf /etc/supervisor/conf.d/gui.conf
  37. # If no gui
  38. RUN if [ "$G4F_NO_GUI" ] ; then \
  39. rm /etc/supervisor/conf.d/gui.conf \
  40. ; fi
  41. # Change background image
  42. COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
  43. # Add user, fix permissions
  44. RUN groupadd -g $G4F_USER_ID $G4F_USER \
  45. && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
  46. && echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
  47. && mkdir "${SE_DOWNLOAD_DIR}" \
  48. && chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
  49. && chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
  50. # Switch user
  51. USER $G4F_USER_ID
  52. # Set VNC password
  53. RUN mkdir -p ${HOME}/.vnc \
  54. && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
  55. # Set the working directory in the container.
  56. WORKDIR $G4F_DIR
  57. # Copy the project's requirements file into the container.
  58. COPY requirements.txt $G4F_DIR
  59. # Upgrade pip for the latest features and install the project's Python dependencies.
  60. RUN pip install --break-system-packages --upgrade pip \
  61. && pip install --break-system-packages -r requirements.txt \
  62. && pip install --break-system-packages \
  63. undetected-chromedriver selenium-wire \
  64. && pip uninstall -y --break-system-packages \
  65. pywebview plyer
  66. # Copy the entire package into the container.
  67. ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
  68. # Expose ports
  69. EXPOSE 8080 1337