wip
This commit is contained in:
parent
aa96d79e47
commit
1bc33ab912
28 changed files with 94 additions and 18 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/06/11 18:10:26 by maiboyer #+# #+# #
|
# Created: 2025/06/11 18:10:26 by maiboyer #+# #+# #
|
||||||
# Updated: 2025/06/12 22:06:41 by maiboyer ### ########.fr #
|
# Updated: 2025/06/16 15:37:20 by maiboyer ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -15,7 +15,10 @@ all:
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
logs:
|
logs:
|
||||||
docker compose logs -f --colors
|
docker compose logs -f
|
||||||
|
|
||||||
|
down:
|
||||||
|
docker compose down
|
||||||
|
|
||||||
re:
|
re:
|
||||||
$(MAKE) -f ./Docker.mk clean
|
$(MAKE) -f ./Docker.mk clean
|
||||||
|
|
|
||||||
10
Makefile
10
Makefile
|
|
@ -6,16 +6,10 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
# Updated: 2025/06/12 22:06:29 by maiboyer ### ########.fr #
|
# Updated: 2025/06/16 15:36:58 by maiboyer ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
# Objdir
|
|
||||||
SRC_DIR = .
|
|
||||||
|
|
||||||
MSG=
|
|
||||||
NAME=webserv
|
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
GREEN = \033[32m
|
GREEN = \033[32m
|
||||||
BLACK = \033[30m
|
BLACK = \033[30m
|
||||||
|
|
@ -56,8 +50,6 @@ prune:
|
||||||
logs:
|
logs:
|
||||||
@$(MAKE) --no-print-directory -f ./Docker.mk logs
|
@$(MAKE) --no-print-directory -f ./Docker.mk logs
|
||||||
|
|
||||||
$(NAME): all
|
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
header:
|
header:
|
||||||
@$(ECHO) -e ''
|
@$(ECHO) -e ''
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ services:
|
||||||
# service_name:
|
# service_name:
|
||||||
# build: ./service_name
|
# build: ./service_name
|
||||||
# container_name: service_name
|
# container_name: service_name
|
||||||
# image: service_name
|
|
||||||
# restart: always
|
# restart: always
|
||||||
# env_file:
|
# env_file:
|
||||||
# - ${SECRET_DIR}/service_name.env
|
# - ${SECRET_DIR}/service_name.env
|
||||||
|
|
@ -24,8 +23,20 @@ services:
|
||||||
- transcendance-network
|
- transcendance-network
|
||||||
ports:
|
ports:
|
||||||
- '8888:443'
|
- '8888:443'
|
||||||
enviroment:
|
environment:
|
||||||
- NGINX_DOMAIN=local.maix.me
|
- NGINX_DOMAIN=local.maix.me
|
||||||
|
- NGINX_USE_LOCAL_RESOLVER=yes
|
||||||
|
|
||||||
|
icons-service:
|
||||||
|
build: ./src/icons-service/
|
||||||
|
container_name: icons-service
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- transcendance-network
|
||||||
|
volumes:
|
||||||
|
- /store
|
||||||
|
environment:
|
||||||
|
- USER_ICONS_STORE=/store
|
||||||
volumes:
|
volumes:
|
||||||
# service_name-vol:
|
# service_name-vol:
|
||||||
# driver: local
|
# driver: local
|
||||||
|
|
|
||||||
15
nginx/15-local-resolvers.envsh
Executable file
15
nginx/15-local-resolvers.envsh
Executable file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# if $NGINX_RESOLVERS set to local, set it to the local resolvers from /etc/resolv.conf and export it
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
LC_ALL=C
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
|
NGINX_RESOLVERS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {if ($2 ~ ":") {print "["$2"]"} else {print $2}}' /etc/resolv.conf)
|
||||||
|
# remove trailing space
|
||||||
|
NGINX_RESOLVERS="${NGINX_RESOLVERS% }"
|
||||||
|
echo "_${NGINX_RESOLVERS}_"
|
||||||
|
|
||||||
|
export NGINX_RESOLVERS
|
||||||
|
|
@ -4,6 +4,7 @@ set -e
|
||||||
|
|
||||||
ME=$(basename "$0")
|
ME=$(basename "$0")
|
||||||
|
|
||||||
|
echo "_{$NGINX_LOCAL_RESOLVERS}_"
|
||||||
entrypoint_log() {
|
entrypoint_log() {
|
||||||
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
||||||
echo "$@"
|
echo "$@"
|
||||||
|
|
@ -19,7 +20,7 @@ auto_template() {
|
||||||
entrypoint_log "$ME: ERROR: $template_dir exists, but is not writable"
|
entrypoint_log "$ME: ERROR: $template_dir exists, but is not writable"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
find "$template_dir" -follow -type f -print | while read -r template; do
|
find "$template_dir" -follow -type f -name '*.conf' -print | while read -r template; do
|
||||||
entrypoint_log "$ME: adding $suffix to $template"
|
entrypoint_log "$ME: adding $suffix to $template"
|
||||||
mv "$template" "$template$suffix"
|
mv "$template" "$template$suffix"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/06/12 16:42:38 by maiboyer #+# #+# #
|
# Created: 2025/06/12 16:42:38 by maiboyer #+# #+# #
|
||||||
# Updated: 2025/06/12 18:15:38 by maiboyer ### ########.fr #
|
# Updated: 2025/06/16 16:26:48 by maiboyer ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -20,6 +20,6 @@ RUN mkdir -p /etc/nginx/ && \
|
||||||
-keyout /etc/ssl/private/nginx-selfsigned.key \
|
-keyout /etc/ssl/private/nginx-selfsigned.key \
|
||||||
-out /etc/ssl/certs/nginx-selfsigned.crt \
|
-out /etc/ssl/certs/nginx-selfsigned.crt \
|
||||||
-subj "/C=FR/OU=student/CN=${NGINX_DOMAIN}"
|
-subj "/C=FR/OU=student/CN=${NGINX_DOMAIN}"
|
||||||
|
COPY ./15-local-resolvers.envsh /docker-entrypoint.d/
|
||||||
COPY ./17-add-template-prefix.sh /docker-entrypoint.d/
|
COPY ./17-add-template-prefix.sh /docker-entrypoint.d/
|
||||||
COPY ./conf /etc/nginx/templates
|
COPY ./conf /etc/nginx/templates
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ server {
|
||||||
charset UTF-8;
|
charset UTF-8;
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
|
resolver $NGINX_RESOLVERS;
|
||||||
server_name $NGINX_DOMAIN;
|
server_name $NGINX_DOMAIN;
|
||||||
|
|
||||||
if ($host = $NGINX_DOMAIN) {
|
if ($host = $NGINX_DOMAIN) {
|
||||||
|
|
@ -17,6 +17,7 @@ server {
|
||||||
listen [::]:443 ssl;
|
listen [::]:443 ssl;
|
||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
server_name $NGINX_DOMAIN;
|
server_name $NGINX_DOMAIN;
|
||||||
|
resolver $NGINX_RESOLVERS;
|
||||||
|
|
||||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||||
|
|
|
||||||
4
nginx/conf/locations/icons.conf
Normal file
4
nginx/conf/locations/icons.conf
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
location /api/icons {
|
||||||
|
rewrite ^/api/icons/(.*) /$1 break;
|
||||||
|
proxy_pass http://icons-service/$uri$is_args$args;
|
||||||
|
}
|
||||||
2
src/icons-service/.dockerignore
Normal file
2
src/icons-service/.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
31
src/icons-service/Dockerfile
Normal file
31
src/icons-service/Dockerfile
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Dockerfile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2025/06/16 14:57:11 by maiboyer #+# #+# #
|
||||||
|
# Updated: 2025/06/16 15:28:33 by maiboyer ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
FROM node:24-alpine AS builder
|
||||||
|
|
||||||
|
# Don't forget to edit the .dockerignore if needed
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
RUN npm install && npm run build:ts;
|
||||||
|
|
||||||
|
FROM node:24-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/package*.json .
|
||||||
|
|
||||||
|
RUN npm ci --omit=dev;
|
||||||
|
# Start the app
|
||||||
|
CMD ["node", "dist/run.js"]
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "user-icons",
|
"name": "icons-service",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "This project was bootstrapped with Fastify-CLI.",
|
"description": "This project was bootstrapped with Fastify-CLI.",
|
||||||
"main": "app.ts",
|
"main": "app.ts",
|
||||||
16
src/icons-service/src/run.ts
Normal file
16
src/icons-service/src/run.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// this sould only be used by the docker file !
|
||||||
|
|
||||||
|
import fastify, { FastifyInstance } from "fastify";
|
||||||
|
import app from './app.js'
|
||||||
|
|
||||||
|
const start = async () => {
|
||||||
|
const f: FastifyInstance = fastify({logger: true});
|
||||||
|
try {
|
||||||
|
await f.register(app, {});
|
||||||
|
await f.listen({ port: 80, host: '0.0.0.0' })
|
||||||
|
} catch (err) {
|
||||||
|
f.log.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue