Build to docker

This commit is contained in:
Fred Boniface 2024-05-01 14:41:08 +01:00
parent 8f6a5aebb8
commit 2079968b5a
4 changed files with 13 additions and 10 deletions

View File

@ -5,11 +5,14 @@ RUN npm install
COPY . . COPY . .
RUN npm run build RUN npm run build
FROM node:14 FROM node:22
RUN apt-get update && apt-get install -y ghostscript RUN apt-get update && apt-get install -y ghostscript
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/package*.json ./ COPY --from=builder /usr/src/app/package*.json ./
COPY --from=builder /usr/src/app/build ./dist COPY --from=builder /usr/src/app/build ./
RUN npm install --only=production COPY ./sh ./sh
COPY ./views ./views
COPY ./static ./static
RUN npm install --omit=dev
EXPOSE 3000 EXPOSE 3000
CMD ["node", "dist/index.js"] CMD ["node", "./index.js"]

View File

@ -65,8 +65,8 @@ export class JobManager {
const presets: { [preset: string]: string } = { const presets: { [preset: string]: string } = {
screen: './sh/screen.sh', screen: './sh/screen.sh',
print: './print_ghostscript.sh', print: './sh/print.sh',
monochrome: './monochrome_ghostscript.sh' monochrome: './sh/monochrome.sh'
}; };
export function createJobId(): string { export function createJobId(): string {
@ -76,8 +76,8 @@ export function createJobId(): string {
export async function runGhostscript(ctx: context, opts: options): Promise<void> { export async function runGhostscript(ctx: context, opts: options): Promise<void> {
ctx.jobManager.create_job(ctx.jobId) ctx.jobManager.create_job(ctx.jobId)
ctx.jobManager.set_job_state(ctx.jobId, "pending") ctx.jobManager.set_job_state(ctx.jobId, "pending")
// Add some kind of limit here to prevent too many jobs from being spawned
await delay(1000) await delay(7500) // Currently a rate limiting delay is introduced
const inputFilePath = `./uploads/${ctx.jobId}/in.pdf` const inputFilePath = `./uploads/${ctx.jobId}/in.pdf`
const outputFilePath = `./uploads/${ctx.jobId}/out.pdf` const outputFilePath = `./uploads/${ctx.jobId}/out.pdf`
ctx.jobManager.set_job_state(ctx.jobId, "running") ctx.jobManager.set_job_state(ctx.jobId, "running")

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"dev": "npx tsc && cp -r static/ build && node build/index.js", "dev": "npx tsc && cp -r static/ build && node build/index.js",
"build": "npx tsc && cp -r static/ views/ sh/ build" "build": "npx tsc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -12,7 +12,7 @@ gs -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \ -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \ -dPDFSETTINGS=/ebook \
-dConvertCMYKImagesToRGB=true \ -dConvertCMYKImagesToRGB=true \
-dColorConversionStrategy=/DeviceGray \ # Adjust color conversion strategy -dColorConversionStrategy=/DeviceGray \
-dEmbedAllFonts=true \ -dEmbedAllFonts=true \
-dSubsetFonts=true \ -dSubsetFonts=true \
-dFastWebView=true \ -dFastWebView=true \