Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.git
.gitignore
.gitattributes
.remember/
.dockerignore

Game/C/datafiles/*.txt
Game/C/executables/*.exe

Game/Java/.metadata/
Game/Java/.settings/
Game/Java/.classpath
Game/Java/.project
Game/Java/target/classes/
Game/Java/target/maven-archiver/
Game/Java/target/maven-status/

frontend/node_modules/
frontend/build/

api/vendor/

configuration.php
configuration.ini
config.ini
frontend/config.env
frontend/.env*
devops_config/.env

**/.vscode/
**/.idea/
**/__pycache__/
Game/server/env-py/
documents/
*.md
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* text=auto eol=lf

*.sh text eol=lf
*.bat text eol=crlf

*.bin binary
*.lex binary
*.jar binary
*.exe binary
*.png binary
*.jpg binary
*.ico binary
*.ser binary
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ Game/server/env-py/
Game/server/data/__pycache__
Game/server/classes/__pycache__
api/vendor
documents/reporting
documents/reporting
devops_config/.env
devops_config/demo.env
2 changes: 1 addition & 1 deletion Game/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pip install -r requirements.txt
Si vous n'avez pas de fichier `requirements.txt`, vous pouvez installer le module websockets manuellement :

```bash
pip install websockets
pip install websockets==13.1
```

## Utilisation
Expand Down
2 changes: 1 addition & 1 deletion Game/server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
websockets
websockets==13.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Technolgie | Version | Partie associée |
<span style="color: #68A063">Node.js<span> | ``20.12`` | Site react
<span style="color: #CB3837">NPM</span> | ``10.5`` | Site react
<span style="color: #885630">Composer</span> | ``2.7`` | API PHP
<span style="color: #777BB4">PHP</span> | ``8.2`` | API PHP
<span style="color: #777BB4">PHP</span> | ``8.3`` | API PHP
<span style="color: #B22222">Java</span> | ``19`` | Moteur de jeu
<span style="color: #FFD343">Python</span> | ``3.12`` | Serveur jeu multijoueur

Expand Down
65 changes: 53 additions & 12 deletions devops_config/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
# Ici ça compose
# PAS TOUCHER
# C'est pour le déploiement de l'application
# 02/02/2024 - Pour PVE
x-app: &app
image: linksawordkening:latest
build:
context: ..
dockerfile: devops_config/dockerimage.dockerfile
args:
REACT_APP_API_URL: ${APP_API_URL}
REACT_APP_WS_URL: ${APP_WS_URL}
WS_PATH: ${WS_PATH:-/game}
Comment on lines +6 to +9
restart: 'unless-stopped'
init: true
security_opt:
- no-new-privileges:true

services:
web:
image: linksawordkening:latest
entrypoint: bash /var/www/html/init.sh
<<: *app
environment:
DB_HOST: ${DB_HOST:?}
DB_NAME: ${DB_NAME:?}
DB_USER: ${DB_USER:?}
DB_PASS: ${DB_PASS:?}
JWT_SECRET: ${JWT_SECRET:?}
JWT_DOMAIN: ${JWT_DOMAIN:?}
MAIL_ADDRESS: ${MAIL_ADDRESS:-}
MAIL_PASSWORD: ${MAIL_PASSWORD:-}
APP_HOST: ${APP_HOST:?}
APP_API_URL: ${APP_API_URL:?}
ports:
- "${WEB_PORT:?WEB_PORT manquant dans devops_config/.env}:80"
deploy:
resources:
limits:
cpus: "2.0"
memory: 384M
pids: 512
healthcheck:
test: ["CMD-SHELL", "curl -fsS --max-time 5 -o /dev/null http://127.0.0.1/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s

game:
<<: *app
command: /usr/local/bin/game-server.sh
ports:
- "xxxx:80"
- "8765:8765"
volumes:
- lechemin:/var/www/html
restart: 'unless-stopped'
stop_grace_period: 30s
deploy:
resources:
limits:
cpus: "4.0"
memory: 512M
cpus: "2.0"
memory: 768M
pids: 512
healthcheck:
test: ["CMD-SHELL", "curl -sS --max-time 5 -o /dev/null http://127.0.0.1:8765/; rc=$$?; [ $$rc -ne 28 ] && [ $$rc -ne 7 ]"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
33 changes: 33 additions & 0 deletions devops_config/configuration.docker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

$required = ['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'JWT_SECRET', 'JWT_DOMAIN', 'APP_HOST', 'APP_API_URL'];
$missing = array_filter($required, static fn(string $v): bool => getenv($v) === false || getenv($v) === '');

if ($missing !== []) {
http_response_code(500);
exit('Configuration incomplete: ' . implode(', ', $missing));
}

$config = [
'database' => [
'host' => getenv('DB_HOST'),
'db' => getenv('DB_NAME'),
'login' => getenv('DB_USER'),
'password' => getenv('DB_PASS'),
],

'PHPMailer' => [
'mailadress' => getenv('MAIL_ADDRESS'),
'mailpassword' => getenv('MAIL_PASSWORD'),
],

'links' => [
'host' => getenv('APP_HOST'),
'apiURL' => getenv('APP_API_URL'),
],

'JWT' => [
'secretKey' => getenv('JWT_SECRET'),
'domainName' => getenv('JWT_DOMAIN'),
],
];
4 changes: 4 additions & 0 deletions devops_config/demo-seed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INSERT INTO la_user (username, birthYear, email, password, verified, profilPicture, visibility, admin)
VALUES ('demo', 2000, 'demo@example.test', '$2y$10$moRKU1qQq0IpLY/alZeCqOHMCspBNJUccs4jClnaYoMRAVT.TIK7K', 1, '/img/profilepictures/strawberry.jpg', 'PUBLIC', 1);
INSERT INTO la_user (username, birthYear, email, password, verified, profilPicture, visibility, admin)
VALUES ('joueur2', 2000, 'joueur2@example.test', '$2y$10$moRKU1qQq0IpLY/alZeCqOHMCspBNJUccs4jClnaYoMRAVT.TIK7K', 1, '/img/profilepictures/strawberry.jpg', 'PUBLIC', 0);
59 changes: 59 additions & 0 deletions devops_config/demo.compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
services:
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASS:-demoroot}
MYSQL_DATABASE: ${DB_NAME:-linksawordkening}
MYSQL_USER: ${DB_USER:-demo}
MYSQL_PASSWORD: ${DB_PASS:-demopass}
volumes:
- ../documents/bdd/linksawordkening-db.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
- ./demo-seed.sql:/docker-entrypoint-initdb.d/02-seed.sql:ro
- db-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${DB_ROOT_PASS:-demoroot}"]
interval: 5s
timeout: 5s
retries: 30
restart: unless-stopped

web:
image: linksawordkening:demo
build:
context: ..
dockerfile: devops_config/dockerimage.dockerfile
args:
REACT_APP_API_URL: http://${PUBLIC_HOST:-localhost}:${WEB_PORT:-8080}/api/
REACT_APP_WS_URL: ws://${PUBLIC_HOST:-localhost}:${WS_PORT:-8765}/game
WS_PATH: /game
environment:
DB_HOST: db
DB_NAME: ${DB_NAME:-linksawordkening}
DB_USER: ${DB_USER:-demo}
DB_PASS: ${DB_PASS:-demopass}
JWT_SECRET: ${JWT_SECRET:-demo0000000000000000000000000000000000000000000000000000000000}
JWT_DOMAIN: ${PUBLIC_HOST:-localhost}
MAIL_ADDRESS: demo@example.test
MAIL_PASSWORD: unused
APP_HOST: http://${PUBLIC_HOST:-localhost}:${WEB_PORT:-8080}/
APP_API_URL: http://${PUBLIC_HOST:-localhost}:${WEB_PORT:-8080}/api/
ports:
- "${WEB_PORT:-8080}:80"
depends_on:
db:
condition: service_healthy
restart: unless-stopped
init: true

game:
image: linksawordkening:demo
command: /usr/local/bin/game-server.sh
ports:
- "${WS_PORT:-8765}:8765"
depends_on:
- web
restart: unless-stopped
init: true

volumes:
db-data:
Loading