Skip to content

Latest commit

 

History

History
178 lines (127 loc) · 5.87 KB

local-setup.md

File metadata and controls

178 lines (127 loc) · 5.87 KB

Local Setup

Requirements

Pre-Setup

NVM

NVM is used in this project to ensure that the correct version of Node is being used. This is not a requirement, but it is highly recommended. If you do not wish to use NVM, you can simply install the correct version of Node on your host machine and skip the NVM setup.

To install NVM, follow the instructions on the NVM GitHub page | Installing and Updating

After installing NVM, you can install the correct version of Node by running the following command in the root of the project:

nvm install

This will install the version of Node specified in the .nvmrc file. You can then use this version of Node by running the following command:

nvm use

Details on how to automatically use the correct version of Node when entering the project directory can be found on the NVM GitHub page | Deeper Shell Integration

Local hosts file

In order to access the application in a web browser either in local or remote development you will need to place the following in your local /etc/hosts (or equivalent) file:

127.0.0.1 aidingapp.local
127.0.0.1 mail.tools.aidingapp.local
127.0.0.1 redis.tools.aidingapp.local
127.0.0.1 storage.tools.aidingapp.local
127.0.0.1 media.tools.aidingapp.local
127.0.0.1 aidingapp-minio
127.0.0.1 test.aidingapp.local

Note: If you want any other tenant domains other than test.aidingapp.local you will need to add them to your etc/hosts file in the same way as well.

Setup

1. Set up the .env file

First, create an .env file based on .env.example

cp .env.example .env

2. Install NPM Dependencies

npm ci
npm run build

3. Install Composer Dependencies

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php82-composer:latest \
    composer install --ignore-platform-reqs

4. Start the containers and open a shell into the main PHP container

Run the following command to start the containers:

spin up -d

Once the containers are started you can now start a shell into the main PHP container by running the following command:

spin exec -it -u webuser aidingapp.local bash

All following commands will and should be run from within the PHP container.


5. Set up the application

We will set up the application by running the following commands:

php artisan migrate:landlord:fresh
php artisan key:generate
php artisan queue:restart
php artisan schedule:interrupt
npm run build

The above commands will set up the application for the "landlord" database. The landlord database is in charge of holding all information on tenants. Next we will set up a tenant.

php artisan tenants:create [A Name for the Tenant] [A domain for the tenant]

These commands will create a new tenant with the name and domain you supplied and then refresh and seed the tenant's database.

After this the application should be accessible at the domain you supplied.

Spin can be stopped by running spin stop and turning back on by running spin up -d

Setup is now complete.


Customizing container settings and Ports

Within the .env.example (and within the .env after you copy it) should exist the following variables:

FORWARD_DB_PORT=5434
FORWARD_REDIS_PORT=63793

Those variable will allow you to edit particular settings and forwarding ports for your local containers. A great example of this usage is within the database section below.

Accessing the Database

Within the containers, Postgres lives on port 5432. And by default it can be accessed outside of the containers on the port set with FORWARD_DB_PORT.

If the port set with FORWARD_DB_PORT is already in use on your system or you prefer to use another port, you can set the FORWARD_DB_PORT in your .env file to whatever available port you want.

Minio (S3 Compatible Storage)

Minio is a S3 compatible storage solution that is used for storing files locally.

When first setting up you will need to create a bucket. This can be done by going to storage.tools.aidingapp.local in your browser and logging in with aidingapp as the username and password as the password. Once logged in, you can create a bucket.

By default, the application is set up in the .env.example to reference a bucket named local. Create a bucket with this name in Minio. Then change its access policy to "Custom" with the following policy configuration:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::local/PUBLIC/*"
            ]
        }
    ]
}

Queue and Scheduler

The application should automatically start a queue worker and scheduler when you run spin up -d. If you preferred to not have these running. You can see the corresponding env variables to false like so:

LARAVEL_SCHEDULER_ENABLED=false
LARAVEL_QUEUE_ENABLED=false