2024-03-16 11:42:36 +03:00
|
|
|
FROM seleniarm/node-chromium
|
2023-12-06 11:35:36 +03:00
|
|
|
|
2023-12-07 09:18:05 +03:00
|
|
|
ARG G4F_VERSION
|
2024-01-02 01:20:48 +03:00
|
|
|
ARG G4F_USER=g4f
|
|
|
|
ARG G4F_USER_ID=1000
|
2023-12-11 04:50:33 +03:00
|
|
|
ARG G4F_NO_GUI
|
2024-01-02 01:20:48 +03: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 22:17:02 +03:00
|
|
|
ENV G4F_NO_GUI $G4F_NO_GUI
|
2024-01-02 01:20:48 +03: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 04:50:33 +03:00
|
|
|
ENV HOME /home/$G4F_USER
|
2024-01-02 01:20:48 +03:00
|
|
|
ENV PATH $PATH:$HOME/.local/bin
|
2023-12-16 22:17:02 +03: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 11:35:36 +03:00
|
|
|
|
|
|
|
USER root
|
|
|
|
|
2023-12-11 04:50:33 +03:00
|
|
|
# If docker compose, install git
|
|
|
|
RUN if [ "$G4F_VERSION" = "" ] ; then \
|
|
|
|
apt-get -qqy update && \
|
|
|
|
apt-get -qqy install git \
|
|
|
|
; fi
|
|
|
|
|
2024-04-22 12:31:47 +03:00
|
|
|
# Install Python3, pip, remove OpenJDK 11, clean up
|
2023-12-06 11:35:36 +03:00
|
|
|
RUN apt-get -qqy update \
|
2024-04-22 12:31:47 +03:00
|
|
|
&& apt-get -qqy install python3 python-is-python3 pip \
|
|
|
|
&& apt-get -qyy remove openjdk-11-jre-headless \
|
2023-12-06 11:35:36 +03:00
|
|
|
&& apt-get -qyy autoremove \
|
2024-04-22 12:31:47 +03:00
|
|
|
&& apt-get -qyy clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
2023-12-06 11:35:36 +03:00
|
|
|
|
|
|
|
# Update entrypoint
|
2023-12-06 13:54:50 +03:00
|
|
|
COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
|
2023-12-11 04:50:33 +03: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 11:35:36 +03:00
|
|
|
|
|
|
|
# Change background image
|
2023-12-07 09:18:05 +03:00
|
|
|
COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
|
2023-12-06 11:35:36 +03:00
|
|
|
|
2024-04-22 12:31:47 +03:00
|
|
|
# Add user, fix permissions
|
2024-01-02 01:20:48 +03: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 12:31:47 +03: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 22:17:02 +03:00
|
|
|
|
|
|
|
# Switch user
|
2023-12-11 04:50:33 +03:00
|
|
|
USER $G4F_USER_ID
|
2023-12-06 11:35:36 +03:00
|
|
|
|
2024-01-02 01:20:48 +03:00
|
|
|
# Set VNC password
|
|
|
|
RUN mkdir -p ${HOME}/.vnc \
|
|
|
|
&& x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
|
|
|
|
|
2023-12-06 11:35:36 +03:00
|
|
|
# Set the working directory in the container.
|
2023-12-11 04:50:33 +03:00
|
|
|
WORKDIR $G4F_DIR
|
2023-12-06 11:35:36 +03:00
|
|
|
|
|
|
|
# Copy the project's requirements file into the container.
|
2023-12-11 04:50:33 +03:00
|
|
|
COPY requirements.txt $G4F_DIR
|
2023-12-06 11:35:36 +03:00
|
|
|
|
|
|
|
# Upgrade pip for the latest features and install the project's Python dependencies.
|
2024-03-26 23:45:53 +03:00
|
|
|
RUN pip install --break-system-packages --upgrade pip \
|
2024-04-23 06:44:49 +03:00
|
|
|
&& pip install --break-system-packages -r requirements.txt \
|
|
|
|
&& pip install --break-system-packages \
|
2024-03-26 23:45:53 +03:00
|
|
|
undetected-chromedriver selenium-wire \
|
|
|
|
&& pip uninstall -y --break-system-packages \
|
2024-04-23 06:44:49 +03:00
|
|
|
pywebview plyer
|
2023-12-06 11:35:36 +03:00
|
|
|
|
|
|
|
# Copy the entire package into the container.
|
2023-12-24 21:28:22 +03:00
|
|
|
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
2023-12-06 11:35:36 +03:00
|
|
|
|
|
|
|
# Expose ports
|
2024-03-16 11:42:36 +03:00
|
|
|
EXPOSE 8080 1337
|