-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (55 loc) · 1.88 KB
/
Dockerfile
File metadata and controls
69 lines (55 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Use Python 3.11 slim image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies required for Playwright, monitoring and health checks
RUN apt-get update && apt-get install -y \
wget \
gnupg \
curl \
procps \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Install Playwright and browsers
RUN playwright install firefox
RUN playwright install-deps
# Copy application code
COPY . .
# Create directories for data persistence and ensure proper permissions
RUN mkdir -p /app/files/job_tracking /app/files/cache /app/files/auth /app/logs && \
chmod -R 755 /app/files && \
chmod -R 755 /app/logs && \
chmod -R 755 /app/scripts
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PROMETHEUS_MULTIPROC_DIR=/tmp
ENV PYTHONPATH=/app
ENV UPWORK_SEARCH_QUERY="AI agent Developer"
ENV FREELANCER_PROFILE_PATH="/app/files/profile.md"
ENV POLLING_INTERVAL=480
ENV MAX_JOBS_PER_POLL=10
ENV JOB_RETENTION_DAYS=30
ENV HIGH_VALUE_THRESHOLD=7.0
ENV WEBHOOK_URL="https://n8n.fy.studio/webhook/a9a844f3-d651-4413-8bf3-820c6877b153"
# Create volume mount points
VOLUME ["/app/files/job_tracking", "/app/files/cache", "/app/files/auth", "/app/logs"]
# Expose health check port
EXPOSE 8000
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD /bin/sh -c '\
curl -f http://localhost:8000/health && \
curl -f http://localhost:8001/metrics && \
ps aux | grep "[p]ython.*continuous_poller" \
|| exit 1'
# Create non-root user
RUN useradd -m -r -s /bin/bash poller && \
chown -R poller:poller /app
# Switch to non-root user
USER poller
# Run the continuous poller with proper error handling
CMD ["python", "-u", "src/continuous_poller.py"]