chore: docker add puppeteer support
This commit is contained in:
parent
bcc215ca5d
commit
23c691541d
11
Dockerfile
11
Dockerfile
@ -7,7 +7,7 @@ COPY ./reporter/ ./reporter/
|
|||||||
RUN apt update
|
RUN apt update
|
||||||
RUN cd reporter && go build .
|
RUN cd reporter && go build .
|
||||||
|
|
||||||
# # Base ------------------------------
|
# Base ------------------------------
|
||||||
FROM node:20-alpine AS base
|
FROM node:20-alpine AS base
|
||||||
|
|
||||||
RUN npm install -g pnpm@9.7.1
|
RUN npm install -g pnpm@9.7.1
|
||||||
@ -32,6 +32,15 @@ RUN pnpm build:static
|
|||||||
FROM base AS app
|
FROM base AS app
|
||||||
WORKDIR /app/tianji
|
WORKDIR /app/tianji
|
||||||
|
|
||||||
|
# We don't need the standalone Chromium
|
||||||
|
ENV PUPPETEER_SKIP_DOWNLOAD=true
|
||||||
|
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
udev \
|
||||||
|
ttf-freefont \
|
||||||
|
chromium
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN pnpm install --filter @tianji/server... --config.dedupe-peer-dependents=false
|
RUN pnpm install --filter @tianji/server... --config.dedupe-peer-dependents=false
|
||||||
|
@ -2,6 +2,9 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
tianji:
|
tianji:
|
||||||
image: moonrailgun/tianji
|
image: moonrailgun/tianji
|
||||||
|
build:
|
||||||
|
context: ./
|
||||||
|
dockerfile: ./Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "12345:12345"
|
- "12345:12345"
|
||||||
environment:
|
environment:
|
||||||
|
@ -52,6 +52,7 @@ export const env = {
|
|||||||
sandboxMemoryLimit: process.env.SANDBOX_MEMORY_LIMIT
|
sandboxMemoryLimit: process.env.SANDBOX_MEMORY_LIMIT
|
||||||
? Number(process.env.SANDBOX_MEMORY_LIMIT)
|
? Number(process.env.SANDBOX_MEMORY_LIMIT)
|
||||||
: 16, // unit: MB
|
: 16, // unit: MB
|
||||||
|
puppeteerExecutablePath: process.env.PUPPETEER_EXECUTABLE_PATH,
|
||||||
dbDebug: checkEnvTrusty(process.env.DB_DEBUG),
|
dbDebug: checkEnvTrusty(process.env.DB_DEBUG),
|
||||||
amapToken: process.env.AMAP_TOKEN,
|
amapToken: process.env.AMAP_TOKEN,
|
||||||
mapboxToken: process.env.MAPBOX_TOKEN,
|
mapboxToken: process.env.MAPBOX_TOKEN,
|
||||||
|
@ -10,7 +10,10 @@ export async function screenshotWebsiteDetailImage(
|
|||||||
websiteId: string,
|
websiteId: string,
|
||||||
userId: string
|
userId: string
|
||||||
) {
|
) {
|
||||||
const browser = await puppeteer.launch({ headless: 'new' });
|
const browser = await puppeteer.launch({
|
||||||
|
executablePath: env.puppeteerExecutablePath,
|
||||||
|
headless: 'new',
|
||||||
|
});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
try {
|
try {
|
||||||
const jwt = jwtSign({
|
const jwt = jwtSign({
|
||||||
|
Loading…
Reference in New Issue
Block a user