better scripts
This commit is contained in:
38
Makefile
Normal file
38
Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
CURRENT_DIR=$(shell basename $(PWD))
|
||||
CURRENT_DIR_LC=$(shell echo $(CURRENT_DIR) | tr A-Z a-z)
|
||||
DOCKER_CONTAINER_NAME=$(CURRENT_DIR_LC)-laravel-1
|
||||
DOCKER_CMD=docker exec -it $(DOCKER_CONTAINER_NAME)
|
||||
|
||||
# Launch the container detached
|
||||
all:
|
||||
docker compose up -d
|
||||
|
||||
# Launch the container
|
||||
run:
|
||||
docker compose up
|
||||
|
||||
# Stop the container
|
||||
stop:
|
||||
docker compose down
|
||||
|
||||
# Stop the container and wipe the database
|
||||
down:
|
||||
docker compose down -v
|
||||
|
||||
|
||||
|
||||
|
||||
# These tasks need the docker container to be running
|
||||
|
||||
exec_container:
|
||||
$(DOCKER_CMD) bash
|
||||
|
||||
seed:
|
||||
$(DOCKER_CMD) php artisan db:seed --class=$(CLASS)
|
||||
|
||||
migrate:
|
||||
$(DOCKER_CMD) php artisan migrate
|
||||
|
||||
init_breeze:
|
||||
$(DOCKER_CMD) composer require laravel/breeze --dev
|
||||
$(DOCKER_CMD) php artisan breeze:install --dark blade
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
Pour lancer les conteneurs :
|
||||
```sh
|
||||
docker compose up
|
||||
make run
|
||||
```
|
||||
|
||||
Les données de la base de données persistent dans le volume docker `laravel_db_volume`
|
||||
|
||||
Les fichiers Laravel sont ensuite disponibles dans le dossier `laravel`
|
||||
Les fichiers Laravel sont ensuite disponibles dans le dossier `laravel`.
|
||||
|
||||
Si vous venez de créer le dossier laravel, supprimer le fichier .env et relancer les contenaurs.
|
||||
|
||||
Le site est ensuite accessible à l'adresse suivante : `http://localhost:8080`
|
||||
@@ -12,7 +12,9 @@ services:
|
||||
- laravel_db_volume:/var/lib/mysql
|
||||
|
||||
laravel:
|
||||
image: bitnami/laravel
|
||||
build:
|
||||
context: images
|
||||
dockerfile: Laravel_Dockerfile
|
||||
ports:
|
||||
- "8080:8000"
|
||||
environment:
|
||||
|
||||
7
images/.env
Normal file
7
images/.env
Normal file
@@ -0,0 +1,7 @@
|
||||
DB_CONNECTION=mariadb
|
||||
DB_HOST=mariadb
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel_db
|
||||
DB_USERNAME=laravel_user
|
||||
DB_PASSWORD=super_strong_password
|
||||
APP_KEY=""
|
||||
8
images/Laravel_Dockerfile
Normal file
8
images/Laravel_Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM bitnami/laravel
|
||||
|
||||
COPY init_laravel.sh /init/init_laravel.sh
|
||||
COPY .env /init/.env
|
||||
|
||||
RUN chmod +x /init/init_laravel.sh
|
||||
|
||||
CMD bash /init/init_laravel.sh
|
||||
11
images/init_laravel.sh
Normal file
11
images/init_laravel.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
composer install
|
||||
|
||||
# Create .env if it does not exist
|
||||
if ! [ -e ".env" ] ; then
|
||||
cp /init/.env .
|
||||
php artisan key:generate
|
||||
fi
|
||||
|
||||
php artisan migrate --force
|
||||
php artisan serve --host=0.0.0.0 --port=8000
|
||||
Reference in New Issue
Block a user