2024-03-16 08:42:36 +00:00
|
|
|
FROM seleniarm/node-chromium
|
2023-12-06 08:35:36 +00:00
|
|
|
|
2023-12-07 06:18:05 +00:00
|
|
|
ARG G4F_VERSION
|
2024-01-01 22:20:48 +00:00
|
|
|
ARG G4F_USER=g4f
|
|
|
|
ARG G4F_USER_ID=1000
|
2023-12-11 01:50:33 +00:00
|
|
|
ARG G4F_NO_GUI
|
2024-01-01 22:20:48 +00:00
|
|
|
ARG G4F_PASS=secret
|
|
|
|
|
|
|
|
ENV G4F_VERSION $G4F_VERSION
|
|
|
|
ENV G4F_USER $G4F_USER
|
|
|
|
ENV G4F_USER_ID $G4F_USER_ID
|
2023-12-16 19:17:02 +00:00
|
|
|
ENV G4F_NO_GUI $G4F_NO_GUI
|
2024-01-01 22:20:48 +00:00
|
|
|
|
|
|
|
ENV SE_SCREEN_WIDTH 1850
|
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
ENV G4F_DIR /app
|
|
|
|
ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=$G4F_PASS
|
2023-12-11 01:50:33 +00:00
|
|
|
ENV HOME /home/$G4F_USER
|
2024-01-01 22:20:48 +00:00
|
|
|
ENV PATH $PATH:$HOME/.local/bin
|
2023-12-16 19:17:02 +00:00
|
|
|
ENV SE_DOWNLOAD_DIR $HOME/Downloads
|
|
|
|
ENV SEL_USER $G4F_USER
|
|
|
|
ENV SEL_UID $G4F_USER_ID
|
|
|
|
ENV SEL_GID $G4F_USER_ID
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
USER root
|
|
|
|
|
2023-12-11 01:50:33 +00:00
|
|
|
# If docker compose, install git
|
|
|
|
RUN if [ "$G4F_VERSION" = "" ] ; then \
|
|
|
|
apt-get -qqy update && \
|
|
|
|
apt-get -qqy install git \
|
|
|
|
; fi
|
|
|
|
|
2023-12-06 08:35:36 +00:00
|
|
|
# Python packages
|
|
|
|
RUN apt-get -qqy update \
|
|
|
|
&& apt-get -qqy install \
|
|
|
|
python3 \
|
|
|
|
python-is-python3 \
|
|
|
|
pip
|
|
|
|
|
2024-01-01 22:20:48 +00:00
|
|
|
# Remove java
|
|
|
|
RUN apt-get -qyy remove openjdk-11-jre-headless
|
|
|
|
|
2023-12-06 08:35:36 +00:00
|
|
|
# Cleanup
|
|
|
|
RUN rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
|
|
|
|
&& apt-get -qyy autoremove \
|
|
|
|
&& apt-get -qyy clean
|
|
|
|
|
|
|
|
# Update entrypoint
|
2023-12-06 10:54:50 +00:00
|
|
|
COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
|
2023-12-11 01:50:33 +00:00
|
|
|
COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
|
|
|
|
|
|
|
|
# If no gui
|
|
|
|
RUN if [ "$G4F_NO_GUI" ] ; then \
|
|
|
|
rm /etc/supervisor/conf.d/gui.conf \
|
|
|
|
; fi
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# Change background image
|
2023-12-07 06:18:05 +00:00
|
|
|
COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
|
2023-12-06 08:35:36 +00:00
|
|
|
|
2023-12-16 19:17:02 +00:00
|
|
|
# Add user
|
2024-01-01 22:20:48 +00:00
|
|
|
RUN groupadd -g $G4F_USER_ID $G4F_USER \
|
|
|
|
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
|
|
|
|
&& echo "${G4F_USER}:${G4F_PASS}" | chpasswd
|
2023-12-16 19:17:02 +00:00
|
|
|
|
|
|
|
# Fix permissions
|
|
|
|
RUN mkdir "${SE_DOWNLOAD_DIR}"
|
|
|
|
RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor
|
2024-01-01 22:20:48 +00:00
|
|
|
RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
|
2023-12-16 19:17:02 +00:00
|
|
|
|
|
|
|
# Switch user
|
2023-12-11 01:50:33 +00:00
|
|
|
USER $G4F_USER_ID
|
2023-12-06 08:35:36 +00:00
|
|
|
|
2024-01-01 22:20:48 +00:00
|
|
|
# Set VNC password
|
|
|
|
RUN mkdir -p ${HOME}/.vnc \
|
|
|
|
&& x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
|
|
|
|
|
2023-12-06 08:35:36 +00:00
|
|
|
# Set the working directory in the container.
|
2023-12-11 01:50:33 +00:00
|
|
|
WORKDIR $G4F_DIR
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# Copy the project's requirements file into the container.
|
2023-12-11 01:50:33 +00:00
|
|
|
COPY requirements.txt $G4F_DIR
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# Upgrade pip for the latest features and install the project's Python dependencies.
|
2024-03-26 20:45:53 +00:00
|
|
|
RUN pip install --break-system-packages --upgrade pip \
|
|
|
|
&& pip install --break-system-packages -r requirements.txt
|
|
|
|
|
|
|
|
# Install selenium driver and uninstall webdriver
|
|
|
|
RUN pip install --break-system-packages \
|
|
|
|
undetected-chromedriver selenium-wire \
|
|
|
|
&& pip uninstall -y --break-system-packages \
|
2024-04-09 23:10:22 +00:00
|
|
|
webdriver plyer nodriver
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# Copy the entire package into the container.
|
2023-12-24 18:28:22 +00:00
|
|
|
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# Expose ports
|
2024-03-16 08:42:36 +00:00
|
|
|
EXPOSE 8080 1337
|