Dockerfile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. FROM selenium/node-chrome
  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. # Python packages
  28. RUN apt-get -qqy update \
  29. && apt-get -qqy install \
  30. python3 \
  31. python-is-python3 \
  32. pip
  33. # Remove java
  34. RUN apt-get -qyy remove openjdk-11-jre-headless
  35. # Cleanup
  36. RUN rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
  37. && apt-get -qyy autoremove \
  38. && apt-get -qyy clean
  39. # Update entrypoint
  40. COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
  41. COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
  42. # If no gui
  43. RUN if [ "$G4F_NO_GUI" ] ; then \
  44. rm /etc/supervisor/conf.d/gui.conf \
  45. ; fi
  46. # Change background image
  47. COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
  48. # Add user
  49. RUN groupadd -g $G4F_USER_ID $G4F_USER \
  50. && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
  51. && echo "${G4F_USER}:${G4F_PASS}" | chpasswd
  52. # Fix permissions
  53. RUN mkdir "${SE_DOWNLOAD_DIR}"
  54. RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor
  55. RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
  56. # Switch user
  57. USER $G4F_USER_ID
  58. # Set VNC password
  59. RUN mkdir -p ${HOME}/.vnc \
  60. && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
  61. # Set the working directory in the container.
  62. WORKDIR $G4F_DIR
  63. # Copy the project's requirements file into the container.
  64. COPY requirements.txt $G4F_DIR
  65. # Upgrade pip for the latest features and install the project's Python dependencies.
  66. RUN pip install --upgrade pip && pip install -r requirements.txt
  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