bos21001 / familiasm-api

MIT License
0 stars 0 forks source link

Set up development environment and create Apiato project #10

Closed bos21001 closed 1 year ago

bos21001 commented 1 year ago

Todo:

bos21001 commented 1 year ago

This will all be set with Laradock with Ngnix, PHP-FPM (8.2) (Apiato 11), Postgres 15 and workspace, by following the instructions below:

Setting up Laradock with Nginx, PHP-FPM 8.2, Apiato 11, Postgres 15, and Workspace

Step 1: Clone Laradock and Apiato repositories

git clone https://github.com/laradock/laradock.git 
git clone git@github.com:bos21001/familiasm-api.git

Step 2: Configure Laradock

Navigate to the Laradock directory and create a .env file by copying the env-example file.

cd laradock
cp env-example .env

Step 3: Configure PHP-FPM version

Open the .env file and set the PHP_FPM_VERSION to 8.2.

PHP_FPM_VERSION=8.2

Step 4: Configure Nginx

  1. Navigate to laradock/nginx/sites.
  2. Copy the default.conf.example to create a new configuration file.
cd nginx/sites cp default.conf.example familiasm-api.conf
  1. Edit the familiasm-api.conf file and configure it for your Apiato project. Replace the root and server_name directives as follows:
server {
    listen 80;
    listen [::]:80;

    server_name familiasm.local;
    root /var/www/familiasm-api/public;

    ...
}

Step 5: Configure Postgres

Open the .env file in the Laradock directory and set the following Postgres settings:

POSTGRES_VERSION=15.0
POSTGRES_DB=your_database_name
POSTGRES_USER=your_user_name
POSTGRES_PASSWORD=your_password

Step 6: Configure Apiato .env

Navigate to the familiasm-api directory and create a .env file by copying the .env.example file.

cd ../../familiasm-api
cp .env.example .env

Edit the .env file to set the DB_CONNECTION settings:

DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=your_database_name
DB_USERNAME=your_user_name
DB_PASSWORD=your_password

Step 7: Run Docker Containers

Navigate back to the Laradock directory and run the following command:

cd ../laradock
docker-compose up -d nginx php-fpm postgres workspace

Step 8: Add Entry to Hosts File

Add an entry to your system's hosts file to map the familiasm.local domain to 127.0.0.1.

# On Linux and macOS
echo "127.0.0.1 familiasm.local api.familiasm.local" | sudo tee -a /etc/hosts

# On Windows
echo "127.0.0.1 familiasm.local api.familiasm.local" >> %SystemRoot%\System32\drivers\etc\hosts

Step 9: Install Composer Dependencies

Execute the following command to install the composer dependencies for your Apiato project:

docker-compose exec workspace bash -c "cd /var/www/familiasm-api && composer install"

Step 10: Run Apiato Migrations

Execute the following command to run the database migrations for your Apiato project:

docker-compose exec workspace bash -c "cd /var/www/familiasm-api && php artisan migrate"

Step 11: Set Up Passport for Apiato

If your Apiato project uses Laravel Passport, execute the following commands to set it up:

docker-compose exec workspace bash -c "cd /var/www/familiasm-api && php artisan passport:install"

Step 12: Access the Application

You should now be able to access your Apiato application by visiting http://familiasm.local in your web browser.

That's it! You've successfully set up Laradock with Nginx, PHP-FPM (8.2), Apiato 11, Postgres 15, and a workspace. If you need to add more services or customize the configuration, you can do so by editing the .env file in the Laradock directory and the docker-compose.yml file as needed.