-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (42 loc) · 1.35 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (42 loc) · 1.35 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
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0t64 \
curl \
chromium \
chromium-driver \
xvfb \
&& rm -rf /var/lib/apt/lists/*
# Create playwright directory and set permissions
RUN mkdir -p /ms-playwright && \
chown -R root:root /ms-playwright && \
chmod -R 777 /ms-playwright
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# Copy source and install Python dependencies
COPY pyproject.toml .
COPY src/ ./src/
# Increase timeout for large packages like geoclip (40MB+)
RUN pip install --timeout 300 .
RUN PLAYWRIGHT_BROWSERS_PATH=/ms-playwright playwright install chromium --with-deps || true
COPY .env .
# Set Python path and environment variables
ENV PYTHONPATH=/app \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
# Set environment variable for Chrome
ENV CHROME_BIN=/usr/bin/chromium
# Startup script
RUN echo '#!/bin/bash\n\
echo "Starting Xvfb..."\n\
Xvfb :99 -screen 0 1024x768x16 &\n\
export DISPLAY=:99\n\
echo "Starting OpenGeoSpy API..."\n\
exec uvicorn src.api.app:app --host 0.0.0.0 --port 8000' > /app/start.sh && \
chmod +x /app/start.sh
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD curl -f http://localhost:8000/api/health || exit 1
CMD ["/app/start.sh"]