Skip to content
Snippets Groups Projects
Commit 3158820a authored by Abelangel's avatar Abelangel
Browse files

microservice helloworld supp, migrations de la databases faites par le service auth

parent 2c712fe2
No related branches found
No related tags found
No related merge requests found
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
<ng-template #singleChoice> <ng-template #singleChoice>
<div *ngFor="let choix of question.choix"> <div *ngFor="let choix of question.choix">
<div class="form-check"> <div class="form-check">
<input id="formCheck-3" [value]="choix.id" class="form-check-input" name="choices" type="radio" <input [id]="choix.id" [value]="choix.id" class="form-check-input" name="choices" type="radio"
(change)="onRadioChange($event)" [checked]="contain(choix.id)" /> (change)="onRadioChange($event)" [checked]="contain(choix.id)" />
<label for="choix">{{choix.text}}</label> <label [for]="choix.id">{{choix.text}}</label>
</div> </div>
</div> </div>
</ng-template> </ng-template>
......
# Étape 1 : Construction de l'application
FROM node:18 AS builder
# Définir le répertoire de travail
WORKDIR /app
# Copier les fichiers package
COPY package.json package-lock.json ./
# Installer les dépendances
RUN npm install
# Copier les fichiers sources
COPY . .
# Compiler le projet TypeScript
RUN npm run build
# Étape 2 : Image de production
FROM node:18
# Définir le répertoire de travail
WORKDIR /app
# Copier les fichiers nécessaires depuis le builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/prisma ./prisma
COPY package.json ./
COPY .env .env
COPY entrypoint.sh ./entrypoint.sh
# Donner les permissions nécessaires
RUN chmod +x entrypoint.sh
EXPOSE 30992
# Utilisation du script d'entrée
ENTRYPOINT ["sh", "./entrypoint.sh"]
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
\ No newline at end of file
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// This model is not complete. It's a base for you to start working with Prisma.
model User {
id Int @id /// The user's id is the same as their gitlab id
name String?
mail String? @unique
gitlabUsername String @unique
deleted Boolean @default(false)
reponses Reponse[]
participer Participer[]
qcmCree QcmTable[]
}
model QcmTable {
idQCM Int @id @default(autoincrement())
nomQCM String
temps Int
randomOrder Boolean
questions Question[]
codeAcces Int
participer Participer[]
idUserCreator Int
creator User @relation(fields: [idUserCreator], references: [id])
}
model Type {
idType Int @id @default(autoincrement())
nomType String @unique
questions Question[]
}
model Choix {
idChoix Int @id @default(autoincrement())
isCorrect Boolean
idQuestion Int
question Question @relation(fields: [idQuestion], references: [idQuestion], onDelete: Cascade, onUpdate: Cascade)
reponses Reponse[]
nomChoix String
position Int
}
model Question {
idQuestion Int @id @default(autoincrement())
question String
position Int
randomOrder Boolean
nbPtsPositif Int
nbPtsNegatif Int
numeric Float?
idQCM Int
qcm QcmTable @relation(fields: [idQCM], references: [idQCM])
idType Int
type Type @relation(fields: [idType], references: [idType])
choix Choix[]
reponses Reponse[]
isMultiple Boolean
}
model Reponse {
idReponse Int @id @default(autoincrement())
idQuestion Int
question Question @relation(fields: [idQuestion], references: [idQuestion])
idChoix Int?
choix Choix? @relation(fields: [idChoix], references: [idChoix], onDelete: Cascade, onUpdate: Cascade)
idUser Int
user User @relation(fields: [idUser], references: [id])
numeric Float?
@@unique([idQuestion, idUser, idChoix])
}
model Participer {
idUser Int
idQCM Int
user User @relation(fields: [idUser], references: [id])
qcm QcmTable @relation(fields: [idQCM], references: [idQCM])
feedback String
note Float
score Int
heureDebut Int
hasFinished Boolean @default(false)
@@id([idUser, idQCM])
}
import process from 'process';
import logger from '../src/logging/WinstonLogger.js';
import db from '../src/helpers/DatabaseHelper.js';
import Config from '../src/config/Config.js';
async function main() {
await users();
await types();
}
main().then(async () => {
await db.$disconnect();
}).catch(async e => {
logger.error(JSON.stringify(e));
await db.$disconnect();
process.exit(1);
});
//----------------------------------------------------------------------------------------------------------------------------------------------------------
async function users() {
await db.user.upsert({
where: { id: 142 },
update: {
name: 'Michaël Minelli'
},
create: {
id: 142,
name: 'Michaël Minelli',
gitlabUsername: 'michael.minelli',
deleted: false
}
});
if (!Config.production) {
await db.user.upsert({
where: { id: 525 },
update: {
deleted: false
},
create: {
id: 525,
gitlabUsername: 'stephane.malandai',
deleted: false
}
});
}
}
async function types() {
await db.type.upsert({
where: { nomType: 'text' },
update: {},
create: {
nomType: 'text'
}
});
await db.type.upsert({
where: { nomType: 'numerique' },
update: {},
create: {
nomType: 'numerique'
}
});
await db.type.upsert({
where: { nomType: 'vraiFaux' },
update: {},
create: {
nomType: 'vraiFaux'
}
});
console.log("✅ Types de base insérés ou déjà présents.");
}
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth
spec:
replicas: 1
selector:
matchLabels:
app: auth
template:
metadata:
labels:
app: auth
spec:
containers:
- name: auth
image: service-auth
ports:
- containerPort: 8002
---
apiVersion: v1
kind: Service
metadata:
name: auth
spec:
selector:
app: auth
ports:
- port: 8002
targetPort: 8002
type: ClusterIP
\ No newline at end of file
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:latest
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "user"
- name: POSTGRES_PASSWORD
value: "super"
- name: POSTGRES_DB
value: "dbqcm"
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-storage
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
\ No newline at end of file
...@@ -17,10 +17,7 @@ http { ...@@ -17,10 +17,7 @@ http {
} }
location /helloworld {
proxy_pass http://service-helloworld:30992;
include cors.conf;
}
location /reponseCorrect/ { location /reponseCorrect/ {
proxy_pass http://service-correction-qcm:30992; proxy_pass http://service-correction-qcm:30992;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment