Merge branch 'feature/docker' into 'dev'

Feature/docker

See merge request sae-but2/2025-26/gestion-benevoles-association/backend!7
This commit is contained in:
T'JAMPENS QUENTIN p2406187
2025-11-28 07:52:16 +00:00
7 changed files with 106 additions and 35 deletions
+12 -6
View File
@@ -1,8 +1,11 @@
GIT_REPO=
GIT_TOKEN=
APP_NAME=Laravel APP_NAME=Laravel
APP_ENV=local APP_ENV=local
APP_KEY= APP_KEY=
APP_DEBUG=true APP_DEBUG=true
APP_URL=http://localhost APP_URL=http://localhost:8000
APP_LOCALE=en APP_LOCALE=en
APP_FALLBACK_LOCALE=en APP_FALLBACK_LOCALE=en
@@ -20,18 +23,19 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug LOG_LEVEL=debug
DB_CONNECTION=mariadb DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_HOST=mariadb
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=sae_back DB_DATABASE=laravel
DB_USERNAME=root DB_USERNAME=root
DB_PASSWORD= DB_PASSWORD=root
SESSION_DRIVER=database SESSION_DRIVER=database
SESSION_LIFETIME=120 SESSION_LIFETIME=120
SESSION_ENCRYPT=false SESSION_ENCRYPT=false
SESSION_PATH=/ SESSION_PATH=/
SESSION_DOMAIN=null SESSION_DOMAIN=localhost
SESSION_SECURE_COOKIE=false
BROADCAST_CONNECTION=log BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local FILESYSTEM_DISK=local
@@ -63,3 +67,5 @@ AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}" VITE_APP_NAME="${APP_NAME}"
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,localhost:8000
+7 -3
View File
@@ -28,7 +28,11 @@ Exemple configuration base de donnée (.env)
- Installer Docker - Installer Docker
- Lancer les commandes depuis la racine du projet: - Lancer les commandes depuis la racine du projet:
``` ```
docker compose up -d docker compose down -v
docker compose exec laravel php artisan key:generate docker compose up --build -d
docker compose exec laravel php artisan migrate docker exec app-php php artisan key:generate
docker exec app-php php artisan migrate
``` ```
docker compose stop
docker compose start
-23
View File
@@ -1,23 +0,0 @@
services:
laravel:
build: .
container_name: laravel-app
volumes:
- .:/var/www
ports:
- "8000:8000"
depends_on:
- mariadb
command: php artisan serve --host=0.0.0.0 --port=8000
mariadb:
image: mariadb:latest
container_name: mariadb
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
+46
View File
@@ -0,0 +1,46 @@
version: "3.8"
services:
php:
build:
context: .
dockerfile: ./php/Dockerfile
container_name: app-php
volumes:
- ../:/var/www/app
environment:
- GIT_TOKEN=${GIT_TOKEN}
- GIT_REPO=${GIT_REPO}
depends_on:
- mariadb
nginx:
image: nginx
container_name: app-nginx
volumes:
- ../:/var/www/app
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
depends_on:
- php
mariadb:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
ports:
- "3306:3306"
volumes:
- dbdata:/var/lib/mysql
volumes:
dbdata:
networks:
default:
ipam:
config:
- subnet: 192.168.200.0/24
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
APP_DIR=/var/www/app
if [ ! -d "$APP_DIR/.git" ]; then
git clone https://oauth2:${GIT_TOKEN}@${GIT_REPO} $APP_DIR
else
cd $APP_DIR
git pull
fi
cd $APP_DIR
mkdir -p storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
composer install --no-interaction --prefer-dist
exec php-fpm
+16
View File
@@ -0,0 +1,16 @@
server {
listen 80;
root /var/www/app/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
+5 -3
View File
@@ -6,8 +6,10 @@ RUN apt-get update && apt-get install -y \
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
COPY . . WORKDIR /var/www/app
RUN composer install --no-dev --optimize-autoloader ENTRYPOINT ["entrypoint.sh"]
CMD ["php-fpm"]