feat(infra): reworked everything so that a single docker builds all + made sure everything works

This commit is contained in:
Maieul BOYER 2025-07-29 14:01:01 +02:00
parent 68f8d87477
commit 157b06ea4b
7 changed files with 23 additions and 14 deletions

View file

@ -6,18 +6,21 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/07/28 16:33:09 by maiboyer #+# #+# #
# Updated: 2025/07/28 17:46:49 by maiboyer ### ########.fr #
# Updated: 2025/07/29 13:54:54 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
# this file will be used to build everything at once
# then all the other Dockerfiles will just copy from this one...
#
# it'll always be tagged as `ft_transcendance_global`
# it'll always be tagged as `trans_builder`
# this is VERY UGLY
# I didn't find really a lot of other ways to do this thought...
# so yeah have mercy :P
# please do not touch this file unless you know what you are doing :)
FROM node:24-alpine
RUN apk add python3;

View file

@ -6,11 +6,13 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/06/16 14:57:11 by maiboyer #+# #+# #
# Updated: 2025/07/28 17:59:09 by maiboyer ### ########.fr #
# Updated: 2025/07/29 13:53:21 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
FROM trans_builder
CMD ["node", "/src/icons/run.js"]
# do extra stuff that is specific for this service here !
CMD ["node", "/src/icons/dist/run.js"]

View file

@ -6,14 +6,14 @@ import sharp from 'sharp'
const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
// await fastify.register(authMethod, {});
// here we register plugins that will be active for the current fastify instance (aka everything in this function)
await fastify.register(fastifyRawBody, { encoding: false });
// we register a route handler for: `/<USERID_HERE>`
// it sets some configuration options, and set the actual function that will handle the request
fastify.post('/:userid', { config: { rawBody: true, encoding: false } }, async function(request, reply) {
// this is how we get the `:userid` part of things
const userid: string | undefined = (request.params as any)['userid'];
if (userid === undefined) {
@ -21,6 +21,10 @@ const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
}
const image_store: string = fastify.getDecorator('image_store')
const image_path = join(image_store, userid)
//let raw_image_file = await open(image_path + ".raw", "w", 0o666)
//await raw_image_file.write(request.rawBody as Buffer);
//await raw_image_file.close()
try {
let img = sharp(request.rawBody as Buffer);
img.resize({