feat: Add vips dependencies for sharp in backend Dockerfile
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Added `vips-dev` and `vips` to build and runtime dependencies. - Updated installation process to ensure compilation
This commit is contained in:
@ -4,7 +4,6 @@ import { events } from '../db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
// Fastify JSON schema for event body
|
||||
const eventBodyJsonSchema = {
|
||||
@ -114,12 +113,15 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
|
||||
let outBuffer: Buffer | null = null;
|
||||
let outExt = '.webp';
|
||||
try {
|
||||
// Lazy load sharp only when needed
|
||||
const sharp = (await import('sharp')).default;
|
||||
outBuffer = await sharp(inputBuffer)
|
||||
.rotate()
|
||||
.resize({ width: 1600, withoutEnlargement: true })
|
||||
.webp({ quality: 82 })
|
||||
.toBuffer();
|
||||
} catch {
|
||||
} catch (err) {
|
||||
fastify.log.warn({ err }, 'Sharp processing failed, using original image');
|
||||
outBuffer = inputBuffer;
|
||||
// naive extension from mimetype
|
||||
const extFromMime = mime.split('/')[1] || 'bin';
|
||||
|
||||
@ -5,7 +5,6 @@ import { galleryImages } from '../db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
// Fastify JSON schema for gallery image body
|
||||
const galleryBodyJsonSchema = {
|
||||
@ -106,12 +105,15 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
|
||||
let outBuffer: Buffer | null = null;
|
||||
let outExt = '.webp';
|
||||
try {
|
||||
// Lazy load sharp only when needed
|
||||
const sharp = (await import('sharp')).default;
|
||||
outBuffer = await sharp(inputBuffer)
|
||||
.rotate()
|
||||
.resize({ width: 1600, withoutEnlargement: true })
|
||||
.webp({ quality: 82 })
|
||||
.toBuffer();
|
||||
} catch {
|
||||
} catch (err) {
|
||||
fastify.log.warn({ err }, 'Sharp processing failed, using original image');
|
||||
outBuffer = inputBuffer;
|
||||
// naive extension from mimetype
|
||||
const extFromMime = mime.split('/')[1] || 'bin';
|
||||
|
||||
Reference in New Issue
Block a user