diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..7fa6236e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.10-slim + +# Install necessary dependencies, including Chromium and Chromedriver +RUN apt-get update && apt-get install -y \ + wget \ + curl \ + unzip \ + git \ + chromium \ + chromium-driver \ + libx11-6 \ + libxrender1 \ + libxcomposite1 \ + libxi6 \ + libxtst6 \ + libnss3 \ + --no-install-recommends && rm -rf /var/lib/apt/lists/* + +# Ensure the target directory exists before creating the symlink +RUN mkdir -p /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/ +# Create a symlink for chromedriver +RUN ln -s /usr/bin/chromedriver /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver.exe + +# Set the working directory +WORKDIR /app + +# Copy the requirements file and install dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the container +COPY . . + +# Set environment variable to allow Python output to be displayed directly +ENV PYTHONUNBUFFERED=1 + +# The default command to run when the container starts +CMD ["bash"] diff --git a/README.md b/README.md index 2a552ee83..c51ee69eb 100644 --- a/README.md +++ b/README.md @@ -51,14 +51,15 @@ Join our **Telegram community** for: 1. [Introduction](#introduction) 2. [Features](#features) 3. [Installation](#installation) -4. [Configuration](#configuration) -5. [Usage](#usage) -6. [Documentation](#documentation) -7. [Troubleshooting](#troubleshooting) -8. [Conclusion](#conclusion) -9. [Contributors](#contributors) -10. [License](#license) -11. [Disclaimer](#disclaimer) +4. [Docker Setup](#docker-setup) +5. [Configuration](#configuration) +6. [Usage](#usage) +7. [Documentation](#documentation) +8. [Troubleshooting](#troubleshooting) +9. [Conclusion](#conclusion) +10. [Contributors](#contributors) +11. [License](#license) +12. [Disclaimer](#disclaimer) ## Introduction @@ -153,6 +154,88 @@ Auto_Jobs_Applier_AIHawk steps in as a game-changing solution to these challenge pip install -r requirements.txt ``` +## Docker Setup + +This project supports Docker to easily set up and run the development environment without needing to install Python locally. Follow the instructions below to build and run the application using Docker. +> **Note:** This setup has been tested only on a MacBook Pro with an M1 chip. Some steps may vary on other devices or architectures. + +### Prerequisites +- Make sure Docker and Docker Compose are installed on your machine. + - [Using Quartz with Docker and Chromium](#using-quartz-with-docker-and-chromium) + - [Install Docker](https://docs.docker.com/get-docker/) + - [Install Docker Compose](https://docs.docker.com/compose/install/) + - Run application + - [Build the Docker Image](#build-the-docker-image) + - [Running the Application](#running-the-application) + - [Stopping the Application](#stopping-the-application) + + +### Using Quartz with Docker and Chromium + +This section explains how to install Quartz as a standalone application on your host machine, configure IP settings using `xhost`, and run a Chromium-based container to view the browser interface from the container. + + +#### Step 1: Install Quartz on Host +To install Quartz as a standalone application on your host machine: + +1. On **Linux/macOS**: + ```bash + sudo apt-get install quartz +2. Alternatively, download the Quartz package directly from its repository if not available via your package manager. + +#### Step 2: Set IPs Using `xhost` on Host +`xhost` allows access control for X server connections, enabling the container to display the browser UI. + +1. Allow local connections: + ```bash + xhost +local: +2. Allow access from a specific IP (e.g., Mac/Local IP): + ```bash + xhost + + ``` + Find your local IP by running + ```bash + ifconfig | grep inet +3. Verify access: + ```bash + xhost + ``` + You should see the allowed IPs listed + +### Build the Docker Image +1. Clone the repository if you haven't already: + ```bash + git clone https://github.com/eyadfarra/Auto_Jobs_Applier_AIHawk.git + + cd Auto_Jobs_Applier_AIHawk + +2. Build the Docker image: + ```bash + docker-compose build + +### Running the Application +1. Start the application using Docker Compose: + ```bash + docker-compose up -d + +2. Access the running container's shell (for development): + ```bash + docker-compose exec app bash + +3. Run the application from within the container: + ```bash + python main.py + +### Stopping the Application +- To stop the application, run: + ```bash + docker-compose down + + +### Notes +- The application files are mounted as a volume in the container, allowing changes to be reflected immediately. +- The container is set up for a development environment by default. For production deployment, additional configurations might be necessary. + ## Configuration ### 1. secrets.yaml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..cebc7fc33 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + app: + platform: linux/arm64 # Ensure the container is built for ARM64 architecture (M1 Mac) + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/app + - /tmp/.X11-unix:/tmp/.X11-unix # Mount X11 socket from host + environment: + - PYTHONDONTWRITEBYTECODE=1 + - PYTHONUNBUFFERED=1 + - DISPLAY=host.docker.internal:0 # Set DISPLAY for X11 forwarding + shm_size: 2g # Allocate 2GB of shared memory + tty: true \ No newline at end of file