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 { eq } from 'drizzle-orm';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import sharp from 'sharp';
|
|
||||||
|
|
||||||
// Fastify JSON schema for event body
|
// Fastify JSON schema for event body
|
||||||
const eventBodyJsonSchema = {
|
const eventBodyJsonSchema = {
|
||||||
@ -114,12 +113,15 @@ const eventsRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
let outBuffer: Buffer | null = null;
|
let outBuffer: Buffer | null = null;
|
||||||
let outExt = '.webp';
|
let outExt = '.webp';
|
||||||
try {
|
try {
|
||||||
|
// Lazy load sharp only when needed
|
||||||
|
const sharp = (await import('sharp')).default;
|
||||||
outBuffer = await sharp(inputBuffer)
|
outBuffer = await sharp(inputBuffer)
|
||||||
.rotate()
|
.rotate()
|
||||||
.resize({ width: 1600, withoutEnlargement: true })
|
.resize({ width: 1600, withoutEnlargement: true })
|
||||||
.webp({ quality: 82 })
|
.webp({ quality: 82 })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
fastify.log.warn({ err }, 'Sharp processing failed, using original image');
|
||||||
outBuffer = inputBuffer;
|
outBuffer = inputBuffer;
|
||||||
// naive extension from mimetype
|
// naive extension from mimetype
|
||||||
const extFromMime = mime.split('/')[1] || 'bin';
|
const extFromMime = mime.split('/')[1] || 'bin';
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { galleryImages } from '../db/schema.js';
|
|||||||
import { eq } from 'drizzle-orm';
|
import { eq } from 'drizzle-orm';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import sharp from 'sharp';
|
|
||||||
|
|
||||||
// Fastify JSON schema for gallery image body
|
// Fastify JSON schema for gallery image body
|
||||||
const galleryBodyJsonSchema = {
|
const galleryBodyJsonSchema = {
|
||||||
@ -106,12 +105,15 @@ const galleryRoute: FastifyPluginAsync = async (fastify) => {
|
|||||||
let outBuffer: Buffer | null = null;
|
let outBuffer: Buffer | null = null;
|
||||||
let outExt = '.webp';
|
let outExt = '.webp';
|
||||||
try {
|
try {
|
||||||
|
// Lazy load sharp only when needed
|
||||||
|
const sharp = (await import('sharp')).default;
|
||||||
outBuffer = await sharp(inputBuffer)
|
outBuffer = await sharp(inputBuffer)
|
||||||
.rotate()
|
.rotate()
|
||||||
.resize({ width: 1600, withoutEnlargement: true })
|
.resize({ width: 1600, withoutEnlargement: true })
|
||||||
.webp({ quality: 82 })
|
.webp({ quality: 82 })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
fastify.log.warn({ err }, 'Sharp processing failed, using original image');
|
||||||
outBuffer = inputBuffer;
|
outBuffer = inputBuffer;
|
||||||
// naive extension from mimetype
|
// naive extension from mimetype
|
||||||
const extFromMime = mime.split('/')[1] || 'bin';
|
const extFromMime = mime.split('/')[1] || 'bin';
|
||||||
|
|||||||
Reference in New Issue
Block a user