fix: add missing dockerfile deps

This commit is contained in:
max_richter 2025-01-18 01:30:43 +01:00
parent e6def646d6
commit fcd21dc871
2 changed files with 12 additions and 24 deletions

View File

@ -1,31 +1,19 @@
FROM gcr.io/distroless/base-debian11 FROM denoland/deno:alpine-2.1.4
ENV DATA_DIR=/app/data ENV DATA_DIR=/app/data
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0
WORKDIR /app WORKDIR /app
COPY . . COPY . .
# Install necessary libraries and dependencies for Playwright and your application RUN apk add curl libstdc++ gtk+3.0 alsa-lib &&\
RUN apt-get update && apt-get install -y --no-install-recommends \ deno run -A npm:playwright install chromium-headless-shell &&\
curl \ deno install --allow-import --allow-ffi --allow-scripts=npm:sharp@0.33.5-rc.1 -e main.ts &&\
libstdc++6 \ sed -i -e 's/"deno"/"no-deno"/' node_modules/@libsql/client/package.json &&\
libgtk-3-0 \ mkdir -p $DATA_DIR
libnss3 \
libxss1 \ RUN deno task build
libasound2 \
fonts-liberation \
&& curl -fsSL https://deno.land/x/install/install.sh | sh \
&& /root/.deno/bin/deno run -A npm:playwright install firefox \
&& /root/.deno/bin/deno install --allow-import --allow-ffi --allow-scripts=npm:sharp@0.33.5-rc.1 -e main.ts \
&& sed -i -e 's/"deno"/"no-deno"/' node_modules/@libsql/client/package.json \
&& mkdir -p $DATA_DIR \
&& rm -rf /var/lib/apt/lists/*
# Expose port 8000 for the application
EXPOSE 8000 EXPOSE 8000
# Use the Deno binary from the installed path to start the app CMD ["run", "-A", "main.ts"]
CMD ["/root/.deno/bin/deno", "run", "-A", "main.ts"]

View File

@ -1,4 +1,4 @@
import { firefox } from "npm:playwright-extra"; import { chromium } from "npm:playwright-extra";
import { createStreamResponse } from "@lib/helpers.ts"; import { createStreamResponse } from "@lib/helpers.ts";
import StealthPlugin from "npm:puppeteer-extra-plugin-stealth"; import StealthPlugin from "npm:puppeteer-extra-plugin-stealth";
@ -9,7 +9,7 @@ const userAgentStrings = [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36",
]; ];
firefox.use(StealthPlugin()); chromium.use(StealthPlugin());
export async function fetchHtmlWithPlaywright( export async function fetchHtmlWithPlaywright(
fetchUrl: string, fetchUrl: string,
@ -17,7 +17,7 @@ export async function fetchHtmlWithPlaywright(
): Promise<string> { ): Promise<string> {
streamResponse.enqueue("booting up playwright"); streamResponse.enqueue("booting up playwright");
// Launch the Playwright browser // Launch the Playwright browser
const browser = await firefox.launch(); const browser = await chromium.launch();
streamResponse.enqueue("fetching html"); streamResponse.enqueue("fetching html");