Merge branch 'dev' into 'main'

Dev

See merge request sae-but2/2025-26/gestion-benevoles-association/docker!2
This commit is contained in:
JOSSERAND GIOVANNI p2405212
2026-01-29 19:11:11 +00:00
14 changed files with 395 additions and 90 deletions
+10
View File
@@ -0,0 +1,10 @@
BACKEND_GIT_REPO=
FRONTEND_GIT_REPO=
BACKEND_GIT_BRANCH=
FRONTEND_GIT_BRANCH=
GIT_TOKEN=
MYSQL_ROOT_PASSWORD=
MYSQL_DATABASE=
TYPESENSE_API_KEY=
+2
View File
@@ -1 +1,3 @@
.idea .idea
.env
backups/
+15 -89
View File
@@ -1,93 +1,19 @@
# Docker # Gestion des bénévoles d'une association
## Initialisation
Afin d'initialiser le projet il est requis de :
## Getting started - Créer un fichier ``.env`` à la racine
- Copier coller le contenu du fichier ``.env.example``
To make it easy for you to get started with GitLab, here's a list of recommended next steps. - Remplir les variables du fichier .env
- Pour la variable ``GIT_TOKEN`` il est nécessaire de chercher/générer son token sur gitlab dans l'onglet : ``Préférences/User settings/Personal access tokens``
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - Répéter l'opération pour le ``docker/php/.env`` et le ``docker/frontend/.env``
## Add your files
* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://iutbg-gitlab.iutbourg.univ-lyon1.fr/sae-but2/2025-26/gestion-benevoles-association/docker.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
* [Set up project integrations](https://iutbg-gitlab.iutbourg.univ-lyon1.fr/sae-but2/2025-26/gestion-benevoles-association/docker/-/settings/integrations)
## Collaborate with your team
* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
## Test and Deploy
Use the built-in continuous integration in GitLab.
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation ## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. Il suffit ensuite d'ouvrir un terminal, de ce placer à la racine de ce projet et d'exécuter les commandes suivantes :
```bash
## Usage docker compose down -v
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. ```
```bash
## Support docker compose up --build -d
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. ```
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+123
View File
@@ -0,0 +1,123 @@
services:
mariadb:
image: mariadb:latest
container_name: app-mariadb
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
ports:
- "3306:3306"
volumes:
- dbdata:/var/lib/mysql
restart: unless-stopped
php:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: app-php
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- app-code:/var/www/app
- ./docker/php/.env:/tmp/app.env:ro
environment:
- GIT_TOKEN=${GIT_TOKEN}
- BACKEND_GIT_REPO=${BACKEND_GIT_REPO}
- BACKEND_GIT_BRANCH=${BACKEND_GIT_BRANCH}
depends_on:
- mariadb
restart: unless-stopped
healthcheck:
test: [ "CMD-SHELL", "test -d /var/www/app/vendor && pidof php-fpm || exit 1" ]
interval: 5s
timeout: 3s
retries: 20
start_period: 120s
frontend:
build:
context: ./docker/frontend
dockerfile: Dockerfile
container_name: app-frontend
environment:
- GIT_TOKEN=${GIT_TOKEN}
- FRONTEND_GIT_REPO=${FRONTEND_GIT_REPO}
- FRONTEND_GIT_BRANCH=${FRONTEND_GIT_BRANCH}
volumes:
- app-code:/var/www/app
- ./docker/frontend/.env:/tmp/app.env:ro
depends_on:
php:
condition: service_healthy
restart: "no"
nginx:
image: nginx:alpine
container_name: app-nginx
volumes:
- app-code:/var/www/app
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
depends_on:
php:
condition: service_healthy
frontend:
condition: service_completed_successfully
restart: unless-stopped
typesense:
image: typesense/typesense:29.0
container_name: app-typesense
restart: unless-stopped
ports:
- "8108:8108"
volumes:
- typesense-data:/data
environment:
- TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
command: '--data-dir /data --api-key=${TYPESENSE_API_KEY} --enable-cors'
backup:
build:
context: ./docker/backup
dockerfile: Dockerfile
container_name: app-backup
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
volumes:
- ./backups:/backups
restart: unless-stopped
reverb:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: app-reverb
environment:
- GIT_TOKEN=${GIT_TOKEN}
- BACKEND_GIT_REPO=${BACKEND_GIT_REPO}
- BACKEND_GIT_BRANCH=${BACKEND_GIT_BRANCH}
entrypoint: []
command: php artisan reverb:start --host=0.0.0.0 --port=8080
volumes:
- app-code:/var/www/app
ports:
- "8080:8080"
depends_on:
- php
- mariadb
restart: unless-stopped
volumes:
app-code:
dbdata:
typesense-data:
networks:
default:
ipam:
config:
- subnet: 192.168.200.0/24
+14
View File
@@ -0,0 +1,14 @@
FROM alpine:latest
RUN apk add --no-cache mariadb-client bash dcron
RUN mkdir -p /backups
RUN mkdir -p /etc/periodic/daily
COPY backup_db.sh /etc/periodic/daily/backup_db
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /etc/periodic/daily/backup_db
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
DB_USER="root"
DB_PASS="root"
DB_NAME="laravel"
BACKUP_DIR="/backups"
mkdir -p "$BACKUP_DIR"
DAY=$(date +%d)
FILE="$BACKUP_DIR/$DAY.sql"
mysqldump -h mariadb -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" > "$FILE" 2>/dev/null
if [ $? -eq 0 ]; then
echo "[$(date)] Backup $DB_NAME sauvegardé dans $FILE" >> "$BACKUP_DIR/backup.log"
else
echo "[$(date)] ERREUR lors du backup de $DB_NAME" >> "$BACKUP_DIR/backup.log"
fi
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
crond -f -l 2
+11
View File
@@ -0,0 +1,11 @@
VITE_API_URL=
VITE_BROADCASTER=reverb
VITE_REVERB_KEY=local
VITE_REVERB_HOST=127.0.0.1
VITE_REVERB_PORT=8080
VITE_FORCE_TLS=false
VITE_DISABLE_STATS=true
VITE_ENCRYPTED=false
VITE_CLUSTER=mt1
VITE_ENABLED_TRANSPORTS=['ws', 'wss']
+11
View File
@@ -0,0 +1,11 @@
FROM node:20-alpine
WORKDIR /app
RUN apk add --no-cache git bash
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["build"]
+39
View File
@@ -0,0 +1,39 @@
#!/bin/sh
set -e
FRONTEND_DIR=/app
APP_DIR=/var/www/app
PUBLIC_DIR="$APP_DIR/public"
GIT_URL="https://oauth2:${GIT_TOKEN}@${FRONTEND_GIT_REPO}"
MAX_WAIT=300
WAITED=0
while [ ! -f "$APP_DIR/composer.json" ] || [ ! -d "$APP_DIR/vendor" ] || [ ! -d "$APP_DIR/public" ]; do
if [ $WAITED -ge $MAX_WAIT ]; then
exit 1
fi
sleep 3
WAITED=$((WAITED + 3))
done
if [ ! -d "$FRONTEND_DIR/.git" ]; then
git clone -b "${FRONTEND_GIT_BRANCH:-main}" "$GIT_URL" "$FRONTEND_DIR"
else
cd "$FRONTEND_DIR"
git fetch origin
git reset --hard origin/"${FRONTEND_GIT_BRANCH:-main}"
fi
cd "$FRONTEND_DIR"
cp /tmp/app.env .env
npm ci --prefer-offline --no-audit
npm run build
find "$PUBLIC_DIR" -mindepth 1 ! -name 'index.php' ! -name '.htaccess' -delete
cp -r dist/* "$PUBLIC_DIR/"
exit 0
+20
View File
@@ -0,0 +1,20 @@
server {
listen 80;
server_name 127.0.0.1;
root /var/www/app/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME 127.0.0.1;
fastcgi_param HTTPS off;
}
}
+79
View File
@@ -0,0 +1,79 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost:8000
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=localhost
SESSION_SECURE_COOKIE=false
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=local
REVERB_APP_KEY=local
REVERB_APP_SECRET=local
REVERB_HOST=reverb
REVERB_PORT=8080
REVERB_SCHEME=http
PUSHER_APP_CLUSTER="mt1"
CACHE_STORE=file
QUEUE_CONNECTION=sync
FILESYSTEM_DISK=local
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,localhost:8000
TYPESENSE_CONNECTION=typesense
TYPESENSE_API_KEY=xyz
+15
View File
@@ -0,0 +1,15 @@
FROM php:8.4-fpm
RUN apt-get update && apt-get install -y \
git unzip libzip-dev libpng-dev libonig-dev \
&& docker-php-ext-install pdo_mysql zip pcntl
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /var/www/app
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["php-fpm"]
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
set -e
APP_DIR=/var/www/app
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
if [ ! -d "$APP_DIR/.git" ]; then
git clone -b "${BACKEND_GIT_BRANCH:-main}" "$GIT_URL" "$APP_DIR"
else
cd "$APP_DIR"
git fetch origin
git reset --hard origin/"${BACKEND_GIT_BRANCH:-main}"
fi
cd "$APP_DIR"
if [ -f composer.json ]; then
composer update --no-interaction --prefer-dist --optimize-autoloader
fi
cp /tmp/app.env .env
php artisan key:generate --force
php artisan config:clear
php artisan cache:clear
php artisan migrate --force
chown -R www-data:www-data public/ storage bootstrap/cache public vendor
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
exec "$@"