Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Docker Support for Containerized Development #585

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
99 changes: 91 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 + <your-local-ip>
```
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
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Loading