Hide vars Logo

Introduction

Requirements

More details about the technical implementation

Script 'create_zip.sh' to create the zip file with the password:

Script to create the zip file with the password

Running the script 'create_zip.sh':

ls

Store the zip file created in the root of the project:

Where to store Script zip file

Part of the content of the zip:

The content of the zip

How it works:

Running the cmd 'serve.sh' with the param 'load-env-vars':

How in local it works

It creates the .env.dev file

APP_DEBUG='true'
APP_ENV='local'
APP_KEY='base64:TskZ8G06T470vcwJ2eM0loIPfxdCO3jM+c5JMl79pPY='
APP_NAME='JGomes-Site-local'
APP_ROUTE_COOKIE_FLAG='local'
APP_URL='http://127.0.0.1:8000'
LOG_CHANNEL='single'
LOG_DEPRECATIONS_CHANNEL='null'
LOG_LEVEL='debug'
MAIL_FROM_ADDRESS='null'
MAIL_FROM_NAME='JGomes-Site-local'
MAIL_LOG_CHANNEL='emails'
MAIL_MAILER='log'
DB_CONNECTION=mysql
DB_DATABASE=jgomes_site_dev
DB_HOST=127.0.0.1
DB_PASSWORD=pass_dev
DB_PORT=3406
DB_USERNAME=user_dev
RABBIT_API_HOST='http://127.0.0.1:15672/api'
RABBIT_CONSUMERS_LIMIT='2'
RABBIT_HOST='127.0.0.1'
RABBIT_MESSAGE_QUEUE='messages_dev'
RABBIT_PASS='pass_dev'
RABBIT_PORT='5672'
RABBIT_USER='user_dev'
REDIS_DB_APP_LABEL='app'
REDIS_DB_APP_NUM='0'
REDIS_DB_MESSAGES_LABEL='messages'
REDIS_DB_MESSAGES_NUM='1'
REDIS_HOST='redis'
REDIS_PASS='pass_dev'
REDIS_PORT='6379'
REDIS_USER='user_dev'
GC_CLOUD_FILE='messages-latest-backup.json'
GC_CLOUD_PATH='jgomes.site/messages/'
GC_HOST_FILE='messages-latest-backup.json'
GC_HOST_PATH='/storage/db-backups/'......=\n-----END PRIVATE KEY-----\n'
REDIS_DB_TESTS_NUM='2'
REDIS_DB_TESTS_LABEL='locations'
REDIS_HOSTS='app:redis:6379:0,messages:redis:6379:1,locations:redis:6379:2'

It creates the mysql service init-local.sql based on init.sql

-- Drop the development user and database if they exist
DROP USER IF EXISTS '${DB_USERNAME}'@'%';

-- Create the development database if it doesn't exist
CREATE DATABASE IF NOT EXISTS ${DB_DATABASE};

-- Create the development user and grant permissions
CREATE USER '${DB_USERNAME}'@'%' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL PRIVILEGES ON ${DB_DATABASE}.* TO '${DB_USERNAME}'@'%';

-- Flush privileges to apply changes
FLUSH PRIVILEGES;
-- Drop the development user and database if they exist
DROP USER IF EXISTS 'user_dev'@'%';

-- Create the development database if it doesn't exist
CREATE DATABASE IF NOT EXISTS jgomes_site_dev;

-- Create the development user and grant permissions
CREATE USER 'user_dev'@'%' IDENTIFIED BY 'pass_dev';
GRANT ALL PRIVILEGES ON jgomes_site_dev.* TO 'user_dev'@'%';

-- Flush privileges to apply changes
FLUSH PRIVILEGES;

It creates the rabbitmq service definitions-local.sql based on definitions.sql

{
    "exchanges": [
        {
            "name": "${RABBIT_MESSAGE_QUEUE}",
            "vhost": "/",
            "type": "direct",
            "durable": true,
            "auto_delete": false,
            "internal": false,
            "arguments": {}
        }
    ],
    "users": [
        {
            "name": "${RABBIT_USER}",
            "password": "${RABBIT_PASS}",
            "tags": "administrator"
        }
    ],
    "vhosts": [
        {
            "name": "/"
        }
    ],
    "permissions": [
        {
            "user": "${RABBIT_USER}",
            "vhost": "/",
            "configure": ".*",
            "write": ".*",
            "read": ".*"
        }
    ],
    "queues": [
        {
            "name": "${RABBIT_MESSAGE_QUEUE}",
            "vhost": "/",
            "durable": true,
            "auto_delete": false,
            "arguments": {}
        }
    ],
    "bindings": [
        {
            "source": "${RABBIT_MESSAGE_QUEUE}",
            "vhost": "/",
            "destination": "${RABBIT_MESSAGE_QUEUE}",
            "destination_type": "queue",
            "routing_key": "${RABBIT_MESSAGE_QUEUE}",
            "arguments": {}
        }
    ]
}
{
    "exchanges": [
        {
            "name": "messages_dev",
            "vhost": "/",
            "type": "direct",
            "durable": true,
            "auto_delete": false,
            "internal": false,
            "arguments": {}
        }
    ],
    "users": [
        {
            "name": "user_dev",
            "password": "pass_dev",
            "tags": "administrator"
        }
    ],
    "vhosts": [
        {
            "name": "/"
        }
    ],
    "permissions": [
        {
            "user": "user_dev",
            "vhost": "/",
            "configure": ".*",
            "write": ".*",
            "read": ".*"
        }
    ],
    "queues": [
        {
            "name": "messages_dev",
            "vhost": "/",
            "durable": true,
            "auto_delete": false,
            "arguments": {}
        }
    ],
    "bindings": [
        {
            "source": "messages_dev",
            "vhost": "/",
            "destination": "messages_dev",
            "destination_type": "queue",
            "routing_key": "messages_dev",
            "arguments": {}
        }
    ]
}

After the set-up what to do?

Demonstration

( Click on the image to watch the video )

Demonstration video