getting merged anyway lol
This commit is contained in:
parent
3f5cb97501
commit
f9671ea198
10 changed files with 68 additions and 20 deletions
|
|
@ -2,6 +2,12 @@ networks:
|
|||
transcendance-network:
|
||||
driver: bridge
|
||||
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:
|
||||
build: ./nginx
|
||||
container_name: nginx
|
||||
|
|
@ -11,22 +17,32 @@ services:
|
|||
ports:
|
||||
- '8888:443'
|
||||
volumes:
|
||||
# if you need to share files with nginx, you do it here.
|
||||
- images-volume:/volumes/icons
|
||||
environment:
|
||||
# this can stay the same for developpement. This is an alias to `localhost`
|
||||
- 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:
|
||||
# build is a bit strange: it has two parts
|
||||
build:
|
||||
dockerfile: ./src/icons-service/Dockerfile # dockerfile to use
|
||||
context: . # the directory to use as `root` (aka the directory you get with `.`)
|
||||
# the dockerfile to use
|
||||
dockerfile: ./src/icons-service/Dockerfile
|
||||
# the current working directory. This means `.` in Dockerfile
|
||||
context: .
|
||||
container_name: icons-service
|
||||
restart: always
|
||||
networks:
|
||||
- transcendance-network
|
||||
volumes:
|
||||
- images-volume:/store
|
||||
- sqlite-volume:/database
|
||||
environment:
|
||||
- USER_ICONS_STORE=/store
|
||||
- DATABASE_DIR=/database
|
||||
volumes:
|
||||
images-volume:
|
||||
sqlite-volume:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
|
||||
set -e
|
||||
|
||||
ME=$(basename "$0")
|
||||
|
|
|
|||
8
nginx/README.md
Normal file
8
nginx/README.md
Normal 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
|
||||
|
|
@ -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`
|
||||
server {
|
||||
charset UTF-8;
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
location /api/db {
|
||||
add_header Content-Type text/plain;
|
||||
return 200 'db api yay';
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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
|
||||
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;
|
||||
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -6,9 +6,15 @@ 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) {
|
||||
console.log(request.headers);
|
||||
|
||||
// this is how we get the `:userid` part of things
|
||||
const userid: string | undefined = (request.params as any)['userid'];
|
||||
if (userid === undefined) {
|
||||
return await reply.code(403);
|
||||
|
|
|
|||
15
src/utils/README.md
Normal file
15
src/utils/README.md
Normal 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
|
||||
24
src/utils/package-lock.json
generated
24
src/utils/package-lock.json
generated
|
|
@ -178,9 +178,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
|
||||
"integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
|
||||
"integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
|
@ -252,9 +252,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.15.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.32.tgz",
|
||||
"integrity": "sha512-3jigKqgSjsH6gYZv2nEsqdXfZqIFGAV36XYYjf9KGZ3PSG+IhLecqPnI310RvjutyMwifE2hhhNEklOUrvx/wA==",
|
||||
"version": "22.16.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.16.5.tgz",
|
||||
"integrity": "sha512-bJFoMATwIGaxxx8VJPeM8TonI8t579oRvgAuT8zFugJsJZgzqv0Fu8Mhp68iecjzG7cnN3mO2dJQ5uUM2EFrgQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -642,9 +642,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/concurrently": {
|
||||
"version": "9.1.2",
|
||||
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.1.2.tgz",
|
||||
"integrity": "sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==",
|
||||
"version": "9.2.0",
|
||||
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.0.tgz",
|
||||
"integrity": "sha512-IsB/fiXTupmagMW4MNp2lx2cdSN2FfZq78vF90LBB+zZHArbIQZjQtzXCiXnvTxCZSvXanTqFLWBjw2UkLx1SQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -2178,9 +2178,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.25",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
|
||||
"integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
|
||||
"version": "0.3.29",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz",
|
||||
"integrity": "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue