Skip to content

Commit

Permalink
Add install script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Jan 17, 2024
1 parent 01fdab1 commit ab50318
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Most of the example code can be found inside `/plugins/` directory:

### Installation

Please see [SETUP.md](/SETUP.md)
Please see [SETUP.md](SETUP.md)
52 changes: 42 additions & 10 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,57 @@ This will ensure that all linked assets will be found. Should also work without,
Note: You need to install the assets yourself somehow. You can also look into `build.sh` and how the deployment script handles it.
In the end you just have to get them installed somehow for the AssetCompress plugin to pick them up.

#### Use CakeBox as VM
Hot tip: Using [CakeBox](https://github.com/alt3/cakebox) is the fast way to get it working on any OS.
Just follow the docs there, log in and create a project:
#### Use Devilbox as VM
Hot tip: Using [Devilbox](https://github.com/cytopia/devilbox) is the fast way to get it working on any OS.

Just follow the [docs](https://github.com/cytopia/devilbox?tab=readme-ov-file#-quickstart) there.
You need to adjust the `.env` file a bit, though.

Set HTTPD_DOCROOT_DIR for easier work with CakePHP:
```
cakebox application add sandbox.local
HTTPD_DOCROOT_DIR=webroot
```
Then remove that `sandbox.local` folder in /Apps/ and instead clone the sandbox into it.

In this case the hosts entry would more look like:
Set up `/etc/hosts` entries for your domains, e.g.
```
10.33.10.10 cakebox sandbox.local
127.0.0.1 sandbox.local
```
The `add` command from above should automatically do that. If not, adjust your hosts file manually.

Then inside the vagrant machine navigate to `/Apps/sandbox.local/` and execute
Inside the devilbox navigate into `data/www/` dir and clone the sandbox repo
```
./setup
git clone [email protected]:dereuromark/cakephp-sandbox.git sandbox
```
You can also use https if you don't have ssh setup yet.

Now you should be able to start up the containers:
```
docker-composer up -d
```
And log in using
```
./shell.sh
```

Then inside container navigate to `sandbox/` and execute
```
./install.sh
```

Tip: Customize your `bash/bashrc.sh` file.
At the end, add your aliases as well as the cd command:
```
alias c='composer'
...
cd sandbox
````
This way you don't need to navigate inside anymore, it will auto-jump you to the repo root.
#### Use Traefix and docker containers as VM
See https://github.com/dereuromark/sandbox-docker?tab=readme-ov-file#installation
Note: Requires HTTPS setup, but otherwise is quicker.
### Creating Admin User
In case you want to check out the admin area (`/admin`), you want to create an admin user.
You can do that via command line:
Expand Down
16 changes: 8 additions & 8 deletions config/app_custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@

'Datasources' => [
'default' => [
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => '', // Set in your app_local.php
'host' => env('DB_HOST', '127.0.0.1'),
'username' => env('DB_USER', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('DB_DATABASE', ''), // Set in your app_local.php
'quoteIdentifiers' => true,
'url' => env('DB_URL') ?: null,
'flags' => [
Expand All @@ -72,10 +72,10 @@
* The test connection is used during the test suite.
*/
'test' => [
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => '', // Set in your app_local.php
'host' => env('DB_HOST', '127.0.0.1'),
'username' => env('DB_USER', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => 'test', // Set in your app_local.php
'quoteIdentifiers' => true,
'url' => env('DB_URL') ?: null,
'flags' => [
Expand Down
8 changes: 4 additions & 4 deletions config/app_local.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

'Datasources' => [
'default' => [
'password' => '',
'database' => 'cake_sandbox',
'password' => env('DB_PASSWORD', ''),
'database' => env('DB_DATABASE', 'sandbox_local'), // Set in your app_local.php
],

/**
* The test connection is used during the test suite.
*/
'test' => [
'password' => '',
'database' => 'cake_test',
'password' => env('DB_PASSWORD', ''),
'database' => 'test',
],
],

Expand Down
31 changes: 31 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Warning: Only run this once for first install, afterwards run ./setup.sh

set -o pipefail

php composer.phar install

[ ! -f config/app_local.php ] && cp config/app_local.default.php config/app_local.php && echo "ERROR: DB credentials missing, enter them now and run again!" && exit 1

mkdir -p ./tmp
mkdir -p ./logs
mkdir -p ./webroot/js/cjs/
mkdir -p ./webroot/css/ccss/

chmod +x bin/cake

# Database for testing
mysql --host=mariadb --password=geheim -u root -e "create database test";

php composer.phar migrate

bin/cake migrations seed

# Assets
mkdir -p tmp
mkdir -p logs
mkdir -p webroot/js/cjs/
mkdir -p webroot/css/ccss/

bower install --allow-root
php composer.phar assets
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ echo "### ASSETS ###";
#npm install -g bower
#npm install -g ttembed-js
bower install
COMPOSER_ALLOW_SUPERUSER=1 php composer.phar assets

ttembed-js ./webroot/assets/font-awesome/fonts/fontawesome-webfont.ttf

Expand Down

0 comments on commit ab50318

Please sign in to comment.