Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=school
DB_USERNAME=root
DB_DATABASE=schoolapp
DB_USERNAME=schoolapp
DB_PASSWORD=schoolapp

DOCKER_WEBSERVER_HOST=4049
Expand Down
27 changes: 27 additions & 0 deletions dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

if ! [ -x "$(command -v docker-compose)" ]; then
echo 'docker-compose is not installed on your machine. Seems you should run the docker-install executable first to help you go through' >&2
sleep 1
exit 1
fi

COMPOSE="docker-compose"

if [ $# -gt 0 ]; then
if [ "$1" == "artisan" ]; then
shift 1
$COMPOSE run --rm artisan "$@"
elif [ "$1" == "composer" ]; then
shift 1
$COMPOSE run --rm composer "$@"
elif [ "$1" == "rebuild" ]; then
shift 1
$COMPOSE up -d --force-recreate --no-deps --build "$@"
$COMPOSE down
else
$COMPOSE "$@"
fi
else
$COMPOSE ps
fi
10 changes: 6 additions & 4 deletions docker-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
if ! [ -x "$(command -v docker-compose)" ]; then
echo 'docker-compose is not installed thus cannot scaffold your app. Sorry, bud...' >&2
echo 'docker-compose is not installed on your machine' >&2
sleep 1
echo 'Installing docker-compose'
sleep 1
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sleep 1
exit 1
fi

echo "Scaffolding your app using Docker... This will take a while..."
Expand All @@ -10,6 +14,4 @@ sudo docker-compose up -d
sudo docker-compose run --rm composer install
sudo docker-compose run --rm artisan migrate:fresh

export $(grep -v '#.*' .env | xargs)
echo "\nUnifiedtransform is ready on localhost:$DOCKER_WEBSERVER_HOST and localhost:$DOCKER_PHPMYADMIN_HOST for the PHPMyAdmin\n"
sleep 1
22 changes: 18 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,25 @@ Here are `.env` properties you can change:
- `DOCKER_WEBSERVER_HOST` defines the Unifiedtransform port address. default value: `4049`
- `DOCKER_PHPMYADMIN_HOST` defines the PHPMyAdmin port address. default value: `5051`

You can also customize the database name defined on the `DB_DATABASE` property when Docker is being initialized the first time.
You can also customize:

#### Added Commands
- `docker-compose run --rm composer <commands>`
- `docker-compose run --rm artisan <commands>`
- `DB_DATABASE`: the database name
- `DB_USERNAME`: the database username. Fill it other than `root` otherwise you will get trouble ahead
- `DB_PASSWORD`: the database password

And it will be reflected on the database credentials after Docker is finished installing.

#### Added Utility Scripts for Working With docker-compose

Under this project, there is an executable called `dev`.
It contains utility scripts which really comes in handy when you are working with the Docker app, especially `docker-compose` scripts cause it shortens some of `docker-compose` scripts.

Available commands:
- `dev composer <commands>` stands for `docker-compose run --rm composer <commands>`
- `dev artisan <commands>` stands for `docker-compose run --rm artisan <commands>`
- `dev rebuild <service>` to rebuild some services defined in the `docker-compose.yml`

Really saving your time, isn't it?

### Not using a Container:

Expand Down