feat(infra): reworked Dockerfile

- changed from npm to pnpm in Dockerfile => improved install time
    Fixed errors from change in .ts files.
This commit is contained in:
Maieul BOYER 2025-08-03 14:40:48 +02:00
parent 704ce37909
commit 5f9fd5629c
7 changed files with 51 additions and 35 deletions

View file

@ -3,8 +3,11 @@ import fastifyFormBody from '@fastify/formbody'
import fastifyMultipart from '@fastify/multipart'
import { mkdir } from 'node:fs/promises'
import fp from 'fastify-plugin'
import * as db from '@shared/database'
// @ts-ignore: import.meta.glob is a vite thing. Typescript doesn't know this...
const plugins = import.meta.glob('./plugins/**/*.ts', { eager: true });
// @ts-ignore: import.meta.glob is a vite thing. Typescript doesn't know this...
const routes = import.meta.glob('./routes/**/*.ts', { eager: true });
@ -21,13 +24,13 @@ const app: FastifyPluginAsync = async (
): Promise<void> => {
// Place here your custom code!
for (const plugin of Object.values(plugins)) {
void fastify.register(plugin, {});
void fastify.register(plugin as any, {});
}
for (const route of Object.values(routes)) {
void fastify.register(route, {});
void fastify.register(route as any, {});
}
//void fastify.register(MyPlugin, {})
void fastify.register(db.uDatabase as any, {})
void fastify.register(fastifyFormBody, {})
void fastify.register(fastifyMultipart, {})

View file

@ -2,7 +2,6 @@ import { FastifyPluginAsync } from 'fastify'
import { join } from 'node:path'
import { open } from 'node:fs/promises'
import sharp from 'sharp'
import { newUUIDv7 } from '@shared/uuid'
import rawBody from 'raw-body'
const route: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
@ -12,7 +11,7 @@ const route: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
// we register a route handler for: `/<USERID_HERE>`
// it sets some configuration options, and set the actual function that will handle the request
fastify.addContentTypeParser('*', function(request, payload, done) {
fastify.addContentTypeParser('*', function(request, payload, done: any) {
done()
});

View file

@ -2,12 +2,32 @@ import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import nodeExternals from 'rollup-plugin-node-externals'
import path from 'node:path'
import fs from 'node:fs'
function collectDeps(...pkgJsonPaths) {
const allDeps = new Set();
for (const pkgPath of pkgJsonPaths) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
for (const dep of Object.keys(pkg.dependencies || {})) {
allDeps.add(dep);
}
for (const peer of Object.keys(pkg.peerDependencies || {})) {
allDeps.add(peer);
}
}
return Array.from(allDeps);
}
const externals = collectDeps(
'./package.json',
'../@shared/package.json'
);
export default defineConfig({
root: __dirname, // service root
plugins: [tsconfigPaths(), nodeExternals()],
build: {
ssr: true,
outDir: 'dist',
emptyOutDir: true,
@ -17,9 +37,9 @@ export default defineConfig({
fileName: () => 'index.js',
},
rollupOptions: {
external: [],
external: externals,
},
target: 'node24', // or whatever Node version you use
target: 'node22', // or whatever Node version you use
sourcemap: true,
minify: false, // for easier debugging
}