diff --git a/Dockerfile b/Dockerfile index c8ce051..0aed2f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,14 @@ RUN npm install COPY . . RUN npm run build -FROM node:14 +FROM node:22 RUN apt-get update && apt-get install -y ghostscript WORKDIR /usr/src/app COPY --from=builder /usr/src/app/package*.json ./ -COPY --from=builder /usr/src/app/build ./dist -RUN npm install --only=production +COPY --from=builder /usr/src/app/build ./ +COPY ./sh ./sh +COPY ./views ./views +COPY ./static ./static +RUN npm install --omit=dev EXPOSE 3000 -CMD ["node", "dist/index.js"] \ No newline at end of file +CMD ["node", "./index.js"] \ No newline at end of file diff --git a/jobs.ts b/jobs.ts index 1038259..0e25587 100644 --- a/jobs.ts +++ b/jobs.ts @@ -65,8 +65,8 @@ export class JobManager { const presets: { [preset: string]: string } = { screen: './sh/screen.sh', - print: './print_ghostscript.sh', - monochrome: './monochrome_ghostscript.sh' + print: './sh/print.sh', + monochrome: './sh/monochrome.sh' }; export function createJobId(): string { @@ -76,8 +76,8 @@ export function createJobId(): string { export async function runGhostscript(ctx: context, opts: options): Promise { ctx.jobManager.create_job(ctx.jobId) ctx.jobManager.set_job_state(ctx.jobId, "pending") - - await delay(1000) + // Add some kind of limit here to prevent too many jobs from being spawned + await delay(7500) // Currently a rate limiting delay is introduced const inputFilePath = `./uploads/${ctx.jobId}/in.pdf` const outputFilePath = `./uploads/${ctx.jobId}/out.pdf` ctx.jobManager.set_job_state(ctx.jobId, "running") diff --git a/package.json b/package.json index 496d769..a21e82a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "npx tsc && cp -r static/ build && node build/index.js", - "build": "npx tsc && cp -r static/ views/ sh/ build" + "build": "npx tsc" }, "repository": { "type": "git", diff --git a/sh/monochrome.sh b/sh/monochrome.sh index b43dfce..dfd7718 100755 --- a/sh/monochrome.sh +++ b/sh/monochrome.sh @@ -12,7 +12,7 @@ gs -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.4 \ -dPDFSETTINGS=/ebook \ -dConvertCMYKImagesToRGB=true \ - -dColorConversionStrategy=/DeviceGray \ # Adjust color conversion strategy + -dColorConversionStrategy=/DeviceGray \ -dEmbedAllFonts=true \ -dSubsetFonts=true \ -dFastWebView=true \