Skip to content

Commit b15e3c9

Browse files
committed
feat: update Docker configuration and enhance application structure
- Added new entries to .gitignore for 'brain/' and 'samples/' directories. - Updated Makefile to include Docker socket mount for read-only access and added environment variables for MongoDB and Redis container names. - Refactored various files for improved code consistency and readability, including updates to import statements and formatting adjustments. - Enhanced README by removing outdated GitHub action badge. - Updated yarn.lock to include new dependencies and versions for better package management.
1 parent 5b35400 commit b15e3c9

213 files changed

Lines changed: 6557 additions & 5123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dist/
66
.nitro/
77
.cache/
88
.data/
9+
brain/
10+
samples/
911
certificates/
1012
documentation/
1113
node_modules/

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ APP_NAME = "sesame-orchestrator"
1616
# ce qui casse les binaires optionnels (ex. oxc-parser / Nuxt). Nom sans guillemets (APP_NAME en contient).
1717
NODE_MODULES_VOLUME = sesame-orchestrator-node-modules
1818
PLATFORM = "linux/amd64"
19+
# Socket Docker en lecture seule : inspection des volumes/labels du conteneur courant
20+
DOCKER_SOCKET_MOUNT = -v /var/run/docker.sock:/var/run/docker.sock:ro
1921

2022
include .env
2123

@@ -28,6 +30,8 @@ COMMON_NAME = localhost
2830
DAYS_VALID = 365
2931

3032
SESAME_SENTRY_DSN ?= ""
33+
SESAME_MONGO_CONTAINER_NAME ?= $(BASE_NAME)-mongodb
34+
SESAME_REDIS_CONTAINER_NAME ?= $(BASE_NAME)-redis
3135

3236
$(shell mkdir -p $(CERT_DIR))
3337

@@ -48,11 +52,15 @@ build: ## Build the container
4852

4953
simulation: ## Start production environment in simulation mode
5054
@docker run --rm -it \
55+
$(DOCKER_SOCKET_MOUNT) \
5156
-e NODE_ENV=production \
5257
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
5358
-e GIT_BRANCH=$(GIT_BRANCH) \
5459
-e GIT_COMMIT=$(GIT_COMMIT) \
5560
-e DOCKER_TAG=$(DOCKER_TAG) \
61+
-e SESAME_CONTAINER_NAME=$(APP_NAME) \
62+
-e SESAME_MONGO_CONTAINER_NAME=$(SESAME_MONGO_CONTAINER_NAME) \
63+
-e SESAME_REDIS_CONTAINER_NAME=$(SESAME_REDIS_CONTAINER_NAME) \
5664
--add-host host.docker.internal:host-gateway \
5765
--platform $(PLATFORM) \
5866
--network dev \
@@ -76,11 +84,15 @@ simulation: ## Start production environment in simulation mode
7684

7785
prod: ## Start production environment
7886
@docker run --rm -it \
87+
$(DOCKER_SOCKET_MOUNT) \
7988
-e NODE_ENV=production \
8089
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
8190
-e GIT_BRANCH=$(GIT_BRANCH) \
8291
-e GIT_COMMIT=$(GIT_COMMIT) \
8392
-e DOCKER_TAG=$(DOCKER_TAG) \
93+
-e SESAME_CONTAINER_NAME=$(APP_NAME) \
94+
-e SESAME_MONGO_CONTAINER_NAME=$(SESAME_MONGO_CONTAINER_NAME) \
95+
-e SESAME_REDIS_CONTAINER_NAME=$(SESAME_REDIS_CONTAINER_NAME) \
8496
--add-host host.docker.internal:host-gateway \
8597
--platform $(PLATFORM) \
8698
--network dev \
@@ -96,11 +108,15 @@ prod: ## Start production environment
96108
dev: ## Start development environment
97109
@mkdir -p $(CURDIR)/apps/api/logs/handlers
98110
@docker run --rm -it \
111+
$(DOCKER_SOCKET_MOUNT) \
99112
-e NODE_ENV=development \
100113
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
101114
-e GIT_BRANCH=$(GIT_BRANCH) \
102115
-e GIT_COMMIT=$(GIT_COMMIT) \
103116
-e DOCKER_TAG=$(DOCKER_TAG) \
117+
-e SESAME_CONTAINER_NAME=$(APP_NAME) \
118+
-e SESAME_MONGO_CONTAINER_NAME=$(SESAME_MONGO_CONTAINER_NAME) \
119+
-e SESAME_REDIS_CONTAINER_NAME=$(SESAME_REDIS_CONTAINER_NAME) \
104120
--add-host host.docker.internal:host-gateway \
105121
--platform $(PLATFORM) \
106122
--network dev \
@@ -118,6 +134,7 @@ dev: ## Start development environment
118134

119135
debug: ## Start debug environment
120136
@docker run --rm -it \
137+
$(DOCKER_SOCKET_MOUNT) \
121138
-e NODE_ENV=development \
122139
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
123140
-e GIT_BRANCH=$(GIT_BRANCH) \
@@ -151,6 +168,7 @@ install: ## Install dependencies
151168

152169
exec: ## Run a shell in the container
153170
@docker run -it --rm \
171+
$(DOCKER_SOCKET_MOUNT) \
154172
-e NODE_ENV=development \
155173
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
156174
--add-host host.docker.internal:host-gateway \

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/libertech-fr/sesame-orchestrator/total">
77
<img alt="GitHub" src="https://img.shields.io/github/license/libertech-fr/sesame-orchestrator">
88
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/libertech-fr/sesame-orchestrator">
9-
<a href="https://github.com/Libertech-Fr/sesame-orchestrator/actions/workflows/release.yml?event=workflow_dispatch"><img alt="GitHub contributors" src="https://github.com/Libertech-Fr/sesame-orchestrator/actions/workflows/release.yml/badge.svg"></a>
109
</p>
1110
<br>
1211

apps/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@simplewebauthn/server": "^13.3.0",
4242
"@tacxou/nestjs_module_factorydrive": "^1.1.6",
4343
"@tacxou/nestjs_module_factorydrive-s3": "^1.0.5",
44+
"@tacxou/nestjs_module_restools": "^1.0.2",
4445
"ajv": "^8.16.0",
4546
"ajv-errors": "^3.0.0",
4647
"ajv-formats": "^3.0.1",

apps/api/src/_common/abstracts/abstract.service.schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import mongodb from 'mongodb';
2020
import { omit } from 'radash';
2121

2222
@Injectable()
23-
export abstract class AbstractServiceSchema<T extends AbstractSchema | Document = AbstractSchema | Document> extends AbstractService implements ServiceSchemaInterface {
23+
export abstract class AbstractServiceSchema<T extends AbstractSchema | Document = AbstractSchema | Document>
24+
extends AbstractService
25+
implements ServiceSchemaInterface
26+
{
2427
protected abstract _model: Model<T>;
2528

2629
protected constructor(context?: AbstractServiceContext) {

apps/api/src/_common/abstracts/abstract.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export abstract class AbstractService {
3030
this.logger = new Logger(this.serviceName);
3131
this.eventEmitter = context?.eventEmitter;
3232

33-
this._customModuleName = context?.moduleName
34-
this._customServiceName = context?.serviceName
33+
this._customModuleName = context?.moduleName;
34+
this._customServiceName = context?.serviceName;
3535
}
3636

3737
protected get request():
3838
| (Request & {
3939
user?: Express.User & any // eslint-disable-line
40-
})
40+
})
4141
| null {
4242
return this._req || RequestContext.currentContext?.req;
4343
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
export type SesameVolumeCategory = 'api' | 'web' | 'shared';
2+
3+
export interface SesameExpectedVolume {
4+
id: string;
5+
category: SesameVolumeCategory;
6+
mountPoint: string;
7+
label: string;
8+
composeHint: string;
9+
required: boolean;
10+
}
11+
12+
export const SESAME_EXPECTED_VOLUMES: SesameExpectedVolume[] = [
13+
{
14+
id: 'api-jsonforms',
15+
category: 'api',
16+
mountPoint: '/data/apps/api/configs/identities/jsonforms',
17+
label: 'JSONForms identités',
18+
composeHint: './configs/sesame-orchestrator/jsonforms:/data/apps/api/configs/identities/jsonforms',
19+
required: true,
20+
},
21+
{
22+
id: 'api-lifecycle',
23+
category: 'api',
24+
mountPoint: '/data/apps/api/configs/lifecycle',
25+
label: 'Cycle de vie',
26+
composeHint: './configs/sesame-orchestrator/lifecycle:/data/apps/api/configs/lifecycle',
27+
required: true,
28+
},
29+
{
30+
id: 'api-cron',
31+
category: 'api',
32+
mountPoint: '/data/apps/api/configs/cron',
33+
label: 'Tâches cron',
34+
composeHint: './configs/sesame-orchestrator/cron:/data/apps/api/configs/cron',
35+
required: true,
36+
},
37+
{
38+
id: 'api-storage',
39+
category: 'api',
40+
mountPoint: '/data/apps/api/storage',
41+
label: 'Stockage API',
42+
composeHint: './configs/sesame-orchestrator/storage:/data/apps/api/storage',
43+
required: true,
44+
},
45+
{
46+
id: 'api-logs',
47+
category: 'api',
48+
mountPoint: '/data/apps/api/logs',
49+
label: 'Journaux API',
50+
composeHint: './configs/sesame-orchestrator/logs:/data/apps/api/logs',
51+
required: true,
52+
},
53+
{
54+
id: 'api-mail-templates',
55+
category: 'api',
56+
mountPoint: '/data/apps/api/templates',
57+
label: 'Modèles e-mail',
58+
composeHint: './configs/sesame-orchestrator/mail-templates:/data/apps/api/templates',
59+
required: true,
60+
},
61+
{
62+
id: 'api-validations',
63+
category: 'api',
64+
mountPoint: '/data/apps/api/configs/identities/validations',
65+
label: 'Validations identités',
66+
composeHint: './configs/sesame-orchestrator/validations:/data/apps/api/configs/identities/validations',
67+
required: true,
68+
},
69+
{
70+
id: 'web-config',
71+
category: 'web',
72+
mountPoint: '/data/apps/web/config',
73+
label: 'Configuration Web',
74+
composeHint: './configs/sesame-app-manager/config:/data/apps/web/config',
75+
required: true,
76+
},
77+
{
78+
id: 'web-statics',
79+
category: 'web',
80+
mountPoint: '/data/apps/web/src/public/config',
81+
label: 'Statiques Web',
82+
composeHint: './configs/sesame-app-manager/statics:/data/apps/web/src/public/config',
83+
required: true,
84+
},
85+
{
86+
id: 'shared-certificates',
87+
category: 'shared',
88+
mountPoint: '/data/certificates',
89+
label: 'Certificats TLS',
90+
composeHint: './certificates:/data/certificates',
91+
required: true,
92+
},
93+
];
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
import { SetMetadata } from '@nestjs/common'
1+
import { SetMetadata } from '@nestjs/common';
22

3-
export const CRON_CONSOLE_HANDLER_METADATA = 'sesame:cron-console-handler'
3+
export const CRON_CONSOLE_HANDLER_METADATA = 'sesame:cron-console-handler';
44

5-
export type CronConsoleHandlerArgumentType = 'string' | 'number' | 'boolean'
5+
export type CronConsoleHandlerArgumentType = 'string' | 'number' | 'boolean';
66

77
export interface CronConsoleHandlerArgument {
88
/** Nom de l'argument dans options cron / options CLI. */
9-
name: string
10-
label?: string
11-
description?: string
12-
type?: CronConsoleHandlerArgumentType
13-
default?: string | number | boolean
14-
required?: boolean
9+
name: string;
10+
label?: string;
11+
description?: string;
12+
type?: CronConsoleHandlerArgumentType;
13+
default?: string | number | boolean;
14+
required?: boolean;
1515
/** Flag CLI (ex. `--source`). Par défaut : `--${name}`. */
16-
flag?: string
16+
flag?: string;
1717
/** Passe la valeur comme argument positionnel après la commande console. */
18-
positional?: boolean
18+
positional?: boolean;
1919
}
2020

2121
export interface CronConsoleHandlerDescriptor {
22-
handler: string
23-
command: string
24-
label: string
25-
arguments: CronConsoleHandlerArgument[]
22+
handler: string;
23+
command: string;
24+
label: string;
25+
arguments: CronConsoleHandlerArgument[];
2626
}
2727

2828
export interface CronConsoleHandlerOptions {
2929
/** Identifiant handler (ex. `lifecycle-execute`). */
30-
handler: string
30+
handler: string;
3131

3232
/** Commande console complète (ex. `lifecycle execute`). */
33-
command: string
33+
command: string;
3434

3535
/** Libellé affiché dans l'interface d'administration. */
36-
label?: string
36+
label?: string;
3737

3838
/** Arguments CLI suggérés pour la configuration cron. */
39-
arguments?: CronConsoleHandlerArgument[]
39+
arguments?: CronConsoleHandlerArgument[];
4040
}
4141

42-
const cronConsoleHandlerRegistry: CronConsoleHandlerDescriptor[] = []
42+
const cronConsoleHandlerRegistry: CronConsoleHandlerDescriptor[] = [];
4343

4444
export function getCronConsoleHandlers(): CronConsoleHandlerDescriptor[] {
45-
return [...cronConsoleHandlerRegistry].sort((left, right) => left.handler.localeCompare(right.handler))
45+
return [...cronConsoleHandlerRegistry].sort((left, right) => left.handler.localeCompare(right.handler));
4646
}
4747

4848
export const CronConsoleHandler = (options: CronConsoleHandlerOptions) => {
@@ -51,7 +51,7 @@ export const CronConsoleHandler = (options: CronConsoleHandlerOptions) => {
5151
command: options.command,
5252
label: options.label || options.handler,
5353
arguments: options.arguments || [],
54-
})
54+
});
5555

56-
return SetMetadata(CRON_CONSOLE_HANDLER_METADATA, options)
57-
}
56+
return SetMetadata(CRON_CONSOLE_HANDLER_METADATA, options);
57+
};
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { applyDecorators, SetMetadata } from '@nestjs/common'
2-
import { UseRoles as AccessControlUseRoles } from 'nest-access-control'
1+
import { applyDecorators, SetMetadata } from '@nestjs/common';
2+
import { UseRoles as AccessControlUseRoles } from 'nest-access-control';
33

4-
export const META_AC_RULE = 'ac:rule'
4+
export const META_AC_RULE = 'ac:rule';
55

66
export type AcRule = {
7-
resource: string
8-
action: string
9-
possession?: string
10-
}
7+
resource: string;
8+
action: string;
9+
possession?: string;
10+
};
1111

1212
export const UseRoles = (rule: AcRule) =>
13-
applyDecorators(
14-
AccessControlUseRoles(rule as any),
15-
SetMetadata(META_AC_RULE, rule),
16-
)
13+
applyDecorators(AccessControlUseRoles(rule as any), SetMetadata(META_AC_RULE, rule));
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { RuntimeException } from 'node-exceptions'
1+
import { RuntimeException } from 'node-exceptions';
22

33
export class AuthorizationRequiredException extends RuntimeException {
4-
public raw: Error
4+
public raw: Error;
55

66
public constructor(err: Error, path: string) {
7-
super(`Unauthorized to access file ${path}\n${err.message}`, 500, 'E_AUTHORIZATION_REQUIRED')
8-
this.raw = err
7+
super(`Unauthorized to access file ${path}\n${err.message}`, 500, 'E_AUTHORIZATION_REQUIRED');
8+
this.raw = err;
99
}
1010
}

0 commit comments

Comments
 (0)