Skip to content

Commit

Permalink
reformulacao sync, add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lucenarenato committed Apr 24, 2024
1 parent 3b34f3c commit cdc6aa2
Show file tree
Hide file tree
Showing 19 changed files with 339 additions and 176 deletions.
42 changes: 28 additions & 14 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:W0TBdAuziG3quhS2b1KEwKZ++DYB9ZjiRiQKLPBAchM=
APP_DEBUG=false
APP_URL=http://core.test
APP_DEBUG=true
APP_URL=http://laravel.test
# APP_PORT=8000

WWWGROUP=1000
WWWUSER=1000

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
# DB_HOST=127.0.0.1
DB_HOST=host.docker.internal
DB_PORT=3306
DB_DATABASE=arslanhexation_marketplace
DB_USERNAME=root
DB_PASSWORD=
DB_DATABASE=gohighlevel
DB_USERNAME=sail
DB_PASSWORD=password

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand All @@ -27,11 +34,13 @@ MAIL_MAILER=log
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME="mughalarslan996@gmail.com"
MAIL_PASSWORD="nhna vqoh ksyt jool"
MAIL_USERNAME="cpdrenato@gmail.com"
MAIL_PASSWORD=null
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS="mughalarslan996@gmail.com"
MAIL_FROM_ADDRESS="cpdrenato@gmail.com"
MAIL_FROM_NAME="${APP_NAME}"
FORWARD_MAILHOG_PORT=1025
FORWARD_MAILHOG_DASHBOARD_PORT=8025

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand All @@ -46,10 +55,15 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

GHL_CLIENT=63ea30018b7bcaf88f9d9a35-le2tmhr6
GHL_SECRET=f2bcec37-d1c5-4d3c-875e-e8ae3606b05e
GHL_CLIENT=0000
GHL_SECRET=0000

GO_HIGH_LEVEL_REDIRECT=
GO_HIGH_LEVEL_CLIENT_ID=0000
GO_HIGH_LEVEL_SECRET=0000

ZOOM_API_URL="https://api.zoom.us/v2/"
ZOOM_API_KEY="p5sN9H2IRBi73D02plaLPA"
ZOOM_API_SECRET="qRDV6h5mK9jEfU5ASwRyZi1WJHXlfuwn"
ZOOM_API_KEY="zzzz"
ZOOM_API_SECRET="zzzz"

JWT_SECRET=XLi041I2BXphtdjQ9ZchPuX2BOx66uWMqCDTiBS3VIYtDVL3a5PFdkYskhzuhoM6
JWT_SECRET=J35U5XLi041I2BXphtdjQ9ZchPuX2BOx66uWMqCDTiBS3VIYtDVL3a5PFdkYskhzuhoM6
93 changes: 93 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# syntax = docker/dockerfile:experimental

# Default to PHP 8.2, but we attempt to match
# the PHP version from the user (wherever `flyctl launch` is run)
# Valid version values are PHP 7.4+
ARG PHP_VERSION=8.2
ARG NODE_VERSION=18
FROM fideloper/fly-laravel:${PHP_VERSION} as base

# PHP_VERSION needs to be repeated here
# See https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG PHP_VERSION

LABEL fly_launch_runtime="laravel"

# copy application code, skipping files based on .dockerignore
COPY . /var/www/html

RUN composer install --optimize-autoloader --no-dev \
&& mkdir -p storage/logs \
&& php artisan optimize:clear \
&& chown -R www-data:www-data /var/www/html \
&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \
&& echo "MAILTO=\"\"\n* * * * * www-data /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
&& cp .fly/entrypoint.sh /entrypoint \
&& chmod +x /entrypoint

# If we're using Octane...
RUN if grep -Fq "laravel/octane" /var/www/html/composer.json; then \
rm -rf /etc/supervisor/conf.d/fpm.conf; \
if grep -Fq "spiral/roadrunner" /var/www/html/composer.json; then \
mv /etc/supervisor/octane-rr.conf /etc/supervisor/conf.d/octane-rr.conf; \
if [ -f ./vendor/bin/rr ]; then ./vendor/bin/rr get-binary; fi; \
rm -f .rr.yaml; \
else \
mv .fly/octane-swoole /etc/services.d/octane; \
mv /etc/supervisor/octane-swoole.conf /etc/supervisor/conf.d/octane-swoole.conf; \
fi; \
rm /etc/nginx/sites-enabled/default; \
ln -sf /etc/nginx/sites-available/default-octane /etc/nginx/sites-enabled/default; \
fi

# Multi-stage build: Build static assets
# This allows us to not include Node within the final container
FROM node:${NODE_VERSION} as node_modules_go_brrr

RUN mkdir /app

RUN mkdir -p /app
WORKDIR /app
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor

# Use yarn or npm depending on what type of
# lock file we might find. Defaults to
# NPM if no lock file is found.
# Note: We run "production" for Mix and "build" for Vite
RUN if [ -f "vite.config.js" ]; then \
ASSET_CMD="build"; \
else \
ASSET_CMD="production"; \
fi; \
if [ -f "yarn.lock" ]; then \
yarn install --frozen-lockfile; \
yarn $ASSET_CMD; \
elif [ -f "pnpm-lock.yaml" ]; then \
corepack enable && corepack prepare pnpm@latest-7 --activate; \
pnpm install --frozen-lockfile; \
pnpm run $ASSET_CMD; \
elif [ -f "package-lock.json" ]; then \
npm ci --no-audit; \
npm run $ASSET_CMD; \
else \
npm install; \
npm run $ASSET_CMD; \
fi;

# From our base container created above, we
# create our final image, adding in static
# assets that we generated above
FROM base

# Packages like Laravel Nova may have added assets to the public directory
# or maybe some custom assets were added manually! Either way, we merge
# in the assets we generated above rather than overwrite them
COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm
RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \
&& rm -rf /var/www/html/public-npm \
&& chown -R www-data:www-data /var/www/html/public

EXPOSE 8080

ENTRYPOINT ["/entrypoint"]
83 changes: 25 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,28 @@
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>

## About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).

Laravel is accessible, powerful, and provides tools required for large, robust applications.

## Learning Laravel

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

## Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).

### Premium Partners

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[WebReinvent](https://webreinvent.com/)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Jump24](https://jump24.co.uk)**
- **[Redberry](https://redberry.international/laravel/)**
- **[Active Logic](https://activelogic.com)**
- **[byte5](https://byte5.de)**
- **[OP.GG](https://op.gg)**

## Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).

## Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).

## Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.

## License

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
# monstro
# comands

```sh
./vendor/bin/sail artisan --version
./vendor/bin/sail artisan migrate --seed
./vendor/bin/sail artisan migrate:refresh
./vendor/bin/sail artisan db:seed
./vendor/bin/sail artisan livewire:layout
./vendor/bin/sail artisan storage:link
./vendor/bin/sail npm install && npm run dev
```

# MailHog docker-compose env
- with local storage
- web ui on port 8025 with login "test" and password "test"
- smtp on port 2025 with login="" and password=""

## Change login and password

`printf "login:" > mailhog.auth`

`printf "$(sudo docker exec mailhog /bin/sh -c "MailHog bcrypt password")" >> mailhog.auth`
- mailhog - name of docker container mailhog

`cat mailhog.auth`
2 changes: 1 addition & 1 deletion app/Console/Commands/RefreshGhl.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle()

$ghl_integration = Setting::where('name', 'ghl_integration')->first();

$response = Http::asForm()->post('https://services.leadconnectorhq.com/oauth/token', [
$response = Http::asForm()->post('https://laravel.test/oauth/token', [
'client_id' => env('GO_HIGH_LEVEL_CLIENT_ID'),
'client_secret' => env('GO_HIGH_LEVEL_SECRET'),
'grant_type' => 'refresh_token',
Expand Down
10 changes: 5 additions & 5 deletions app/Console/Commands/RefreshGhlTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ public function __construct()
*/
public function handle()
{
\Log::info("ghl-source-token:refresh - Refresh All GHL tokens");
$setting = Setting::where('name', 'ghl_integration')->first();
\Log::info("ghl-source-token:refresh - Refresh All GHL tokens");
$setting = Setting::where('name', 'ghl_integration')->first();
$body = [
'client_id' => env('GO_HIGH_LEVEL_CLIENT_ID'),
'client_secret' => env('GO_HIGH_LEVEL_SECRET'),
'grant_type' => 'refresh_token',
'refresh_token' => $setting->meta_data['refresh_token'],
];


$response = Http::asForm()->post('https://services.leadconnectorhq.com/oauth/token', $body);

$response = Http::asForm()->post('https://laravel.test/oauth/token', $body);

if ($response->successful()) {
$data = $response->json();
Expand All @@ -63,7 +63,7 @@ public function handle()
'meta_data' => $data
]);
} else {
\Log::info("ghl-source-token:refresh - Token Expired");
\Log::info("ghl-source-token:refresh - Token Expired");
\Log::info($response->body());
}
}
Expand Down
26 changes: 13 additions & 13 deletions app/Console/Commands/SyncGhlContactsCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,46 +46,46 @@ public function handle()
try {
$tokenObj = Http::withHeaders([
'Authorization' => 'Bearer '.$token,
'Version' => '2021-07-28'
])->asForm()->post('https://services.leadconnectorhq.com/oauth/locationToken', [
'Version' => '2021-07-28'
])->asForm()->post('https://laravel.test/oauth/locationToken', [
'companyId' => $companyId,
'locationId' => $location->go_high_level_location_id,
]);

if ($tokenObj->failed()) {
Log::info('=== SyncGhlContactsCron === (Location Token) =>'.json_encode($tokenObj->json()));
}

$tokenObj = $tokenObj->json();

do {
$responseCustomField = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$tokenObj['access_token'],
'Version' => '2021-07-28'
])->get('https://services.leadconnectorhq.com/locations/'.$location->go_high_level_location_id.'/customFields');
])->get('https://laravel.test/locations/'.$location->go_high_level_location_id.'/customFields');

if ($responseCustomField->failed()) {
$responseCustomField->throw();
$responseCustomField->throw();
}
$responseCustomField = $responseCustomField->json();

foreach($responseCustomField['customFields'] as $customField) {
if($customField['name'] == 'Program Level') {
$reqCustomField = $customField;
}
}

if($reqCustomField) {
$url = 'https://services.leadconnectorhq.com/contacts/?locationId='.$location->go_high_level_location_id.'&limit=100';
$url = 'https://laravel.test/contacts/?locationId='.$location->go_high_level_location_id.'&limit=100';
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$tokenObj['access_token'],
'Version' => '2021-07-28'
])->get($url);

if ($response->failed()) {
$response->throw();
$response->throw();
}
$response = $response->json();
$contacts = $response['contacts'];
Expand Down Expand Up @@ -119,7 +119,7 @@ public function handle()
if($programLevel) {
MemberController::createMemberFromGHL($contact, $location ,$programLevel->id);
}
}
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/Console/Commands/SyncGhlLocationsCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function handle()
'Will\'s Condo Account',
'Won\'s Taekwondo Education',
];

$ghl_integration = Setting::where('name', 'ghl_integration')->first();

$token = $ghl_integration['value'];
Expand All @@ -83,7 +83,7 @@ public function handle()
$response = Http::withHeaders([
'Authorization' => 'Bearer '.$token,
'Version' => '2021-07-28',
])->get('https://services.leadconnectorhq.com/locations/search?limit=100&skip='.$offset.'&companyId='.$companyId);
])->get('https://laravel.test/locations/search?limit=100&skip='.$offset.'&companyId='.$companyId);

if($response->failed()) {
$response->throw();
Expand All @@ -94,8 +94,8 @@ public function handle()
if(!isset($response_json['locations'])) {
return;
}
$allLocations = $response_json['locations'];

$allLocations = $response_json['locations'];
foreach($allLocations as $index => $location){
try {
if (in_array($location['name'], $ignore_locations)) {
Expand Down Expand Up @@ -152,7 +152,7 @@ public function handle()
// DB::rollBack();
}
}
$offset = $offset + count($allLocations);
$offset = $offset + count($allLocations);
} while(count($allLocations) > 0);
}
}
Loading

0 comments on commit cdc6aa2

Please sign in to comment.