getting merged anyway lol

This commit is contained in:
maix0 2025-07-19 15:29:06 +02:00 committed by Maieul BOYER
parent 3f5cb97501
commit f9671ea198
10 changed files with 68 additions and 20 deletions

View file

@ -2,6 +2,12 @@ networks:
transcendance-network: transcendance-network:
driver: bridge driver: bridge
services: services:
#
# The "entry point" as in it does all of this:
# - serve files (images, static files, video)
# - redirect request to appropirate service (reverse proxy)
# - be the one that handles TLS/SSL (basically HTTPS)
# - other stuff I don't know yet
nginx: nginx:
build: ./nginx build: ./nginx
container_name: nginx container_name: nginx
@ -11,22 +17,32 @@ services:
ports: ports:
- '8888:443' - '8888:443'
volumes: volumes:
# if you need to share files with nginx, you do it here.
- images-volume:/volumes/icons - images-volume:/volumes/icons
environment: environment:
# this can stay the same for developpement. This is an alias to `localhost`
- NGINX_DOMAIN=local.maix.me - NGINX_DOMAIN=local.maix.me
# an example of an micro service. this one basically only does this:
# - handle uploading of icons
# - write icons to shared volume allowing nginx to serve them (does it better than if we did it in the service)
icons-service: icons-service:
# build is a bit strange: it has two parts
build: build:
dockerfile: ./src/icons-service/Dockerfile # dockerfile to use # the dockerfile to use
context: . # the directory to use as `root` (aka the directory you get with `.`) dockerfile: ./src/icons-service/Dockerfile
# the current working directory. This means `.` in Dockerfile
context: .
container_name: icons-service container_name: icons-service
restart: always restart: always
networks: networks:
- transcendance-network - transcendance-network
volumes: volumes:
- images-volume:/store - images-volume:/store
- sqlite-volume:/database
environment: environment:
- USER_ICONS_STORE=/store - USER_ICONS_STORE=/store
- DATABASE_DIR=/database
volumes: volumes:
images-volume: images-volume:
sqlite-volume: sqlite-volume:

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# if $NGINX_RESOLVERS set to local, set it to the local resolvers from /etc/resolv.conf and export it # if $NGINX_RESOLVERS set to local, set it to the local resolvers from /etc/resolv.conf and export it
# DO NOT EDIT THIS FILE
set -eu set -eu

View file

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# DO NOT EDIT THIS FILE
set -e set -e
ME=$(basename "$0") ME=$(basename "$0")

8
nginx/README.md Normal file
View file

@ -0,0 +1,8 @@
# Nginx Configuration
You want to have a new microservice ?
Edit/add a file in `conf/locations/`
take example on `conf/locations/icons.conf` on how to make a reverse proxy and on how to serve static files
# Good Luck Have Fun

View file

@ -1,3 +1,5 @@
# please make sure you want to edit this file...
# this allows the redirection of `http://domain/URL` to `https://domain/URL` # this allows the redirection of `http://domain/URL` to `https://domain/URL`
server { server {
charset UTF-8; charset UTF-8;

View file

@ -1,4 +0,0 @@
location /api/db {
add_header Content-Type text/plain;
return 200 'db api yay';
}

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ # # By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2025/06/16 14:57:11 by maiboyer #+# #+# # # Created: 2025/06/16 14:57:11 by maiboyer #+# #+# #
# Updated: 2025/06/17 16:31:49 by maiboyer ### ########.fr # # Updated: 2025/07/19 15:26:15 by maiboyer ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -17,6 +17,7 @@ FROM node:24-alpine as utils-builder
WORKDIR /app WORKDIR /app
COPY ./src/utils /app COPY ./src/utils /app
RUN apk add python3;
RUN set -x && npm install && npm run build:ts && mkdir /out && cp -r package*.json dist/ /out; RUN set -x && npm install && npm run build:ts && mkdir /out && cp -r package*.json dist/ /out;
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ # ^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -6,9 +6,15 @@ import sharp from 'sharp'
const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => { const example: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
// await fastify.register(authMethod, {}); // 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 }); 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) { fastify.post('/:userid', { config: { rawBody: true, encoding: false } }, async function(request, reply) {
console.log(request.headers);
// this is how we get the `:userid` part of things
const userid: string | undefined = (request.params as any)['userid']; const userid: string | undefined = (request.params as any)['userid'];
if (userid === undefined) { if (userid === undefined) {
return await reply.code(403); return await reply.code(403);

15
src/utils/README.md Normal file
View file

@ -0,0 +1,15 @@
# Utils Library
This library is made to be shared by all of the service.
It should handle things like database interface, shared stuff like 'make sure this is accessed by an connected user'
# How it is used
Painfully.
# Why no Docker ?
Docker compose can't make "build-only" docker images, where we just use them.
So we have to "build" the library in every Dockerfile for every service.
Well not really, dockers caches things for use,
meaning that while it seems that everybody builds it, it is only built once

View file

@ -178,9 +178,9 @@
} }
}, },
"node_modules/@jridgewell/sourcemap-codec": { "node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.0", "version": "1.5.4",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
"integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
@ -252,9 +252,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.15.32", "version": "22.16.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.32.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.16.5.tgz",
"integrity": "sha512-3jigKqgSjsH6gYZv2nEsqdXfZqIFGAV36XYYjf9KGZ3PSG+IhLecqPnI310RvjutyMwifE2hhhNEklOUrvx/wA==", "integrity": "sha512-bJFoMATwIGaxxx8VJPeM8TonI8t579oRvgAuT8zFugJsJZgzqv0Fu8Mhp68iecjzG7cnN3mO2dJQ5uUM2EFrgQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@ -642,9 +642,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/concurrently": { "node_modules/concurrently": {
"version": "9.1.2", "version": "9.2.0",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.1.2.tgz", "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.0.tgz",
"integrity": "sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==", "integrity": "sha512-IsB/fiXTupmagMW4MNp2lx2cdSN2FfZq78vF90LBB+zZHArbIQZjQtzXCiXnvTxCZSvXanTqFLWBjw2UkLx1SQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@ -2178,9 +2178,9 @@
} }
}, },
"node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": {
"version": "0.3.25", "version": "0.3.29",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz",
"integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "integrity": "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {