📅  最后修改于: 2022-03-11 14:54:39.081000             🧑  作者: Mango
*mettre à jour l'OS
sudo apt-get update
apt full-upgrade
*cloner laravel dans un répertoire et se positionner
cd ~
git clone https://github.com/laravel/laravel.git laravel-app
cd ~/laravel-app
*créer les répertoires
docker run --rm -v $(pwd):/app composer install
'si erreur': sudo apt install docker.io
'définir les autorisations': sudo chown -R $USER:$USER ~/laravel-app
*création et édition du docker-compose.yml
nano ~/laravel-app/docker-compose.yml
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: e-real.fr/php
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: your_mysql_root_password
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
*fichier image docker
nano ~/laravel-app/Dockerfile
*créer le fichier local.ini dans le dossier php.
mkdir ~/laravel-app/php
nano ~/laravel-app/php/local.ini 'upload_max_filesize=40M
post_max_size=40M'
*config de nginx
mkdir -p ~/laravel-app/nginx/conf.d
nano ~/laravel-app/nginx/conf.d/app.conf
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
*config mysql
mkdir ~/laravel-app/mysql
nano ~/laravel-app/mysql/my.cnf
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
*Exécution des conteneurs et modification des paramètres
cp .env.example .env
docker-compose up -d
*conteneurs en cours
docker ps
*exec des commandes specifiques dans les conteneurs
docker-compose exec app vim .env