Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Dec 5, 2023
1 parent 0298967 commit ce49f26
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 68 deletions.
26 changes: 26 additions & 0 deletions app/Events/TestEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct()
{
}

public function broadcastOn(): array
{
return [
new Channel('public'),
];
}
}
6 changes: 6 additions & 0 deletions app/Http/Livewire/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class Dashboard extends Component
{
public $projects = [];
public $servers = [];
protected $listeners = ['echo:public,TestEvent' => 'notifyNewOrder'];

public function notifyNewOrder()
{
$this->emit('success', 'New order received!');
}
public function mount()
{
$this->servers = Server::ownedByCurrentTeam()->get();
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
App\Providers\AppServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Expand Down
8 changes: 4 additions & 4 deletions config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY', 'coolify'),
'secret' => env('PUSHER_APP_SECRET', 'coolify'),
'app_id' => env('PUSHER_APP_ID', 'coolify'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => 'coolify-soketi',
'port' => env('PUSHER_PORT', 6001),
'scheme' => env('PUSHER_SCHEME', 'http'),
'encrypted' => false,
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
Expand Down
28 changes: 14 additions & 14 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ services:
SSL_MODE: "off"
AUTORUN_LARAVEL_STORAGE_LINK: "false"
AUTORUN_LARAVEL_MIGRATION: "false"
# PUSHER_HOST: "coolify-soketi"
# PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
# PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
# PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
PUSHER_HOST: "coolify-soketi"
PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
volumes:
- .:/var/www/html/:cached
postgres:
Expand All @@ -48,16 +48,16 @@ services:
volumes:
- /data/coolify/_volumes/redis/:/data
# - coolify-redis-data-dev:/data
# soketi:
# env_file:
# - .env
# ports:
# - "${FORWARD_SOKETI_PORT:-6001}:6001"
# environment:
# SOKETI_DEBUG: "true"
# SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}"
# SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
# SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
soketi:
env_file:
- .env
ports:
- "${FORWARD_SOKETI_PORT:-6001}:6001"
environment:
SOKETI_DEBUG: "false"
SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}"
SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
vite:
image: node:20
working_dir: /var/www/html
Expand Down
15 changes: 9 additions & 6 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ services:
- PHP_PM_START_SERVERS=1
- PHP_PM_MIN_SPARE_SERVERS=1
- PHP_PM_MAX_SPARE_SERVERS=10
- PUSHER_APP_ID
- PUSHER_APP_KEY
- PUSHER_APP_SECRET
- SELF_HOSTED
- WAITLIST
- SUBSCRIPTION_PROVIDER
Expand Down Expand Up @@ -111,12 +114,12 @@ services:
interval: 2s
retries: 5
timeout: 2s
# soketi:
# environment:
# SOKETI_DEBUG: "${SOKETI_DEBUG:-false}"
# SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}"
# SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}"
# SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}"
soketi:
environment:
SOKETI_DEBUG: "${SOKETI_DEBUG:-false}"
SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}"
SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}"
SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}"
volumes:
coolify-db:
name: coolify-db
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ services:
restart: always
networks:
- coolify
# soketi:
# image: 'quay.io/soketi/soketi:latest-16-alpine'
# container_name: coolify-soketi
# restart: always
# networks:
# - coolify
soketi:
image: 'quay.io/soketi/soketi:latest-16-alpine'
container_name: coolify-soketi
restart: always
networks:
- coolify
networks:
coolify:
name: coolify
Expand Down
34 changes: 17 additions & 17 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import Alpine from "alpinejs";
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
import { createApp } from "vue";
import MagicBar from "./components/MagicBar.vue";
import Toaster from "../../vendor/masmerise/livewire-toaster/resources/js";

// window.Pusher = Pusher;

// window.Echo = new Echo({
// broadcaster: 'pusher',
// cluster: window.location.hostname,
// key: import.meta.env.VITE_PUSHER_APP_KEY ?? 'coolify',
// wsHost: window.location.hostname,
// wsPort: 6001,
// wssPort: 6001,
// forceTLS: false,
// encrypted: true,
// disableStats: false,
// enableLogging: true,
// enabledTransports: ['ws', 'wss'],
// });
window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'pusher',
cluster: window.location.hostname,
key: import.meta.env.VITE_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
forceTLS: false,
encrypted: true,
disableStats: false,
enableLogging: true,
enabledTransports: ['ws', 'wss'],
});

Alpine.plugin(Toaster);

Expand Down
4 changes: 4 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse;
use Laravel\Fortify\Fortify;

Route::get('/fire', function () {
event(new \App\Events\TestEvent());
return 'fired';
});
if (isDev()) {
Route::get('/dev/compose', Compose::class)->name('dev.compose');
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ if [ ! -f /data/coolify/source/.env ]; then
sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
sed -i "s|REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env
sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env
sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env
fi

# Merge .env and .env.production. New values will be added to .env
Expand Down
40 changes: 20 additions & 20 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ curl -fsSL $CDN/.env.production -o /data/coolify/source/.env.production
sort -u -t '=' -k 1,1 /data/coolify/source/.env /data/coolify/source/.env.production | sed '/^$/d' >/data/coolify/source/.env.temp && mv /data/coolify/source/.env.temp /data/coolify/source/.env

# Check if PUSHER_APP_ID or PUSHER_APP_KEY or PUSHER_APP_SECRET is empty in /data/coolify/source/.env
# if grep -q "PUSHER_APP_ID=$" /data/coolify/source/.env; then
# echo "PUSHER_APP_ID is not set in .env"
# sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env
# else
# echo "PUSHER_APP_ID is set in .env"
# fi

# if grep -q "PUSHER_APP_KEY=$" /data/coolify/source/.env; then
# echo "PUSHER_APP_KEY is not set in .env"
# sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env
# else
# echo "PUSHER_APP_KEY is set in .env"
# fi

# if grep -q "PUSHER_APP_SECRET=$" /data/coolify/source/.env; then
# echo "PUSHER_APP_SECRET is not set in .env"
# sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env
# else
# echo "PUSHER_APP_SECRET is set in .env"
# fi
if grep -q "PUSHER_APP_ID=$" /data/coolify/source/.env; then
echo "PUSHER_APP_ID is not set in .env"
sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env
else
echo "PUSHER_APP_ID is set in .env"
fi

if grep -q "PUSHER_APP_KEY=$" /data/coolify/source/.env; then
echo "PUSHER_APP_KEY is not set in .env"
sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env
else
echo "PUSHER_APP_KEY is set in .env"
fi

if grep -q "PUSHER_APP_SECRET=$" /data/coolify/source/.env; then
echo "PUSHER_APP_SECRET is not set in .env"
sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env
else
echo "PUSHER_APP_SECRET is set in .env"
fi

# Make sure coolify network exists
docker network create --attachable coolify 2>/dev/null
Expand Down

0 comments on commit ce49f26

Please sign in to comment.