diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2777186 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +__pycache__ +*.py[cod] +*.log +*.sqlite* +*.db +.env +.env.* +.git +.gitignore +playwright-log.txt +/tests diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c67de9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11-slim + +# Install OS dependencies required by Playwright +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + +# Set work directory +WORKDIR /app + +# Install Python dependencies first +COPY requirements.txt . +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt && \ + playwright install --with-deps + +# Copy application code +COPY . . + +EXPOSE 8000 + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index 894b33c..04b5b15 100644 --- a/README.md +++ b/README.md @@ -1 +1,36 @@ -# vehicle-tracker \ No newline at end of file +# Vehicle Tracker + +This project provides a FastAPI service that scrapes vehicle listings from AutoTrader using Playwright and stores them in a database. + +## Local Development + +1. Install dependencies: + ```bash + pip install -r requirements.txt + ``` +2. Start the server: + ```bash + uvicorn app.main:app --reload + ``` + +## Docker Usage + +Build the Docker image using the included helper script: + +```bash +./build.sh +``` + +Alternatively build manually: + +```bash +docker build -t vehicle-tracker . +``` + +Run the container and expose port `8000`: + +```bash +docker run --env-file .env -p 8000:8000 vehicle-tracker +``` + +The API will then be available at `http://localhost:8000`. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..44ca4dc --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e + +docker build -t vehicle-tracker "$@" . + +echo "Image built as vehicle-tracker. Run with:" +echo " docker run --env-file .env -p 8000:8000 vehicle-tracker"