better docker scripts

This commit is contained in:
2025-06-07 11:31:30 +02:00
parent 68a81195e6
commit 563a16256c
6 changed files with 57 additions and 10 deletions

32
Makefile Normal file
View File

@@ -0,0 +1,32 @@
DOCKER_CONTAINER_NAME=isi2-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

7
images/.env Normal file
View 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=""

View File

@@ -4,4 +4,9 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | ba
RUN . ~/.nvm/nvm.sh && nvm install --lts RUN . ~/.nvm/nvm.sh && nvm install --lts
RUN composer require laravel/breeze --dev 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

View File

@@ -1,3 +0,0 @@
composer require laravel/breeze --dev
php artisan breeze:install blade
php artisan migrate

12
images/init_laravel.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/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 breeze:install blade
php artisan migrate --force
php artisan serve --host=0.0.0.0 --port=8000

6
package-lock.json generated
View File

@@ -1,6 +0,0 @@
{
"name": "isi2",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}