fix docker file
This commit is contained in:
parent
ab9346e96b
commit
a04ee0343c
3 changed files with 34 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
|
@ -17,24 +17,41 @@ COPY . .
|
|||
WORKDIR /build/services/scraper-google
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o scraper-google .
|
||||
|
||||
# Runtime stage
|
||||
FROM chromedp/headless-shell:latest
|
||||
# Runtime stage - Use Debian with Chrome installed
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# Install ca-certificates for HTTPS requests
|
||||
# Install Chrome and dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
chromium \
|
||||
chromium-sandbox \
|
||||
fonts-liberation \
|
||||
libasound2 \
|
||||
libatk-bridge2.0-0 \
|
||||
libatk1.0-0 \
|
||||
libatspi2.0-0 \
|
||||
libcups2 \
|
||||
libdbus-1-3 \
|
||||
libdrm2 \
|
||||
libgbm1 \
|
||||
libgtk-3-0 \
|
||||
libnspr4 \
|
||||
libnss3 \
|
||||
libxcomposite1 \
|
||||
libxdamage1 \
|
||||
libxfixes3 \
|
||||
libxkbcommon0 \
|
||||
libxrandr2 \
|
||||
xdg-utils \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set Chrome path for chromedp
|
||||
ENV CHROME_PATH=/usr/bin/chromium
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the binary from builder
|
||||
COPY --from=builder /build/services/scraper-google/scraper-google .
|
||||
|
||||
# Copy environment files if they exist (optional)
|
||||
COPY --from=builder /build/services/scraper-google/.env* ./
|
||||
|
||||
# Expose any ports if needed (not required for this service)
|
||||
# EXPOSE 8080
|
||||
|
||||
# Run the scraper
|
||||
CMD ["./scraper-google"]
|
||||
ENTRYPOINT ["./scraper-google"]
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ func GetHTMLRaw(ctx context.Context, googleLink domain.GoogleLink) (string, stri
|
|||
// Set up chromedp options
|
||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||
chromedp.Flag("headless", true),
|
||||
chromedp.Flag("no-sandbox", true), // Required for Docker
|
||||
chromedp.Flag("disable-gpu", true), // Recommended for Docker
|
||||
chromedp.Flag("disable-dev-shm-usage", true), // Prevents crashes in Docker
|
||||
chromedp.Flag("disable-blink-features", "AutomationControlled"),
|
||||
chromedp.Flag("excludeSwitches", "enable-automation"),
|
||||
chromedp.UserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ func Work(mainCtx context.Context) func(page int, stream chan<- domain.GoogleLin
|
|||
|
||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||
chromedp.Flag("headless", true),
|
||||
chromedp.Flag("no-sandbox", true), // Required for Docker
|
||||
chromedp.Flag("disable-gpu", true), // Recommended for Docker
|
||||
chromedp.Flag("disable-dev-shm-usage", true), // Prevents crashes in Docker
|
||||
chromedp.Flag("disable-blink-features", "AutomationControlled"),
|
||||
chromedp.Flag("excludeSwitches", "enable-automation"),
|
||||
chromedp.Flag("disable-web-security", false),
|
||||
|
|
|
|||
Loading…
Reference in a new issue