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
|
|
|
|
|
2024-04-22 09:31:47 +00:00
|
|
|
# Install Python3, pip, remove OpenJDK 11, clean up
|
2023-12-06 08:35:36 +00:00
|
|
|
RUN apt-get -qqy update \
|
2024-04-22 09:31:47 +00:00
|
|
|
&& apt-get -qqy install python3 python-is-python3 pip \
|
|
|
|
&& apt-get -qyy remove openjdk-11-jre-headless \
|
2023-12-06 08:35:36 +00:00
|
|
|
&& apt-get -qyy autoremove \
|
2024-04-22 09:31:47 +00:00
|
|
|
&& apt-get -qyy clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
2023-12-06 08:35:36 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2024-04-22 09:31:47 +00:00
|
|
|
# Add user, fix permissions
|
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 \
|
2024-04-22 09:31:47 +00:00
|
|
|
&& echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
|
|
|
|
&& mkdir "${SE_DOWNLOAD_DIR}" \
|
|
|
|
&& chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
|
|
|
|
&& 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 \
|
2024-04-23 03:44:49 +00:00
|
|
|
&& pip install --break-system-packages -r requirements.txt \
|
|
|
|
&& pip install --break-system-packages \
|
2024-03-26 20:45:53 +00:00
|
|
|
undetected-chromedriver selenium-wire \
|
|
|
|
&& pip uninstall -y --break-system-packages \
|
2024-04-23 03:44:49 +00:00
|
|
|
pywebview plyer
|
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
|