Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€
(❁´◑`❁)β•°(Β°β–½Β°)β•―(^///^)β˜†*: .q. o(≧▽≦)o .q.:*β˜†:-)α“šα˜α—’(┬┬﹏┬┬)ΰ²₯_ΰ²₯ΰ²₯_ΰ²₯(┬┬﹏┬┬)ΰ²₯_ΰ²₯(┬┬﹏┬┬)ΰ²₯_ΰ²₯(┬┬﹏┬┬)ΰ²₯_ΰ²₯(┬┬﹏┬┬)
  • Loading branch information
DestroyCom committed Sep 16, 2023
2 parents a9c0a66 + 5a63e5e commit 8cf095a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 34 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/install_sera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ jobs:
run: |
docker exec sera-server sh -c 'echo "${{ secrets.PROD_ENV_FILE }}" > .env'
- name: Wait for the database to be ready
run: |
sleep 5
docker exec -u root sera-server apt-get update
docker exec -u root sera-server apt-get install -y netcat-openbsd
docker exec sera-server sh -c 'until nc -z -v -w30 sera-mariadb 3306; do echo "Waiting for database connection..."; sleep 5; done'
docker exec sera-server sh -c 'until nc -z -v -w30 sera-minio 9000; do echo "Waiting for database connection..."; sleep 5; done'
- name: Execute laravel configs
run: |
docker exec sera-server php artisan cache:clear
Expand All @@ -48,9 +56,12 @@ jobs:
docker exec sera-server php artisan optimize
docker exec sera-server php artisan storage:link
docker exec sera-server chown -R www-data:www-data /root
docker exec sera-server /root/minio-binaries/mc alias set myminio http://minio:9000 s3-sera-user SsmHJPoq!d
docker exec sera-server /root/minio-binaries/mc mb --with-versioning --ignore-existing myminio/sera
docker exec sera-server php artisan migrate --force
docker exec sera-server php artisan config:cache
docker exec sera-server php artisan config:clear
sleep 5
docker exec sera-server /root/minio-binaries/mc alias set myminio http://minio:9000 s3SeraUser SsmHJPoqd
sleep 5
docker exec sera-server /root/minio-binaries/mc mb --with-versioning --ignore-existing myminio/sera
sleep 5
docker exec sera-server php artisan migrate --force
docker exec sera-server php artisan db:seed --class=UserProdSeeder --force
23 changes: 15 additions & 8 deletions prod.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ services:
image: destcom/sera-web
ports:
- "6663:80"
restart: on-failure
networks:
- sail
- monolith
- hosted
depends_on:
Expand All @@ -17,16 +19,20 @@ services:
user: "${WWWUSER:-1000}:${WWWGROUP:-1000}"
ports:
- "6664:80"
restart: on-failure
networks:
- sail
- monolith
- hosted
depends_on:
- mariadb
- minio
- mariadb:
condition: service_healthy
- soketi
mariadb:
container_name: sera-mariadb
image: "mariadb:10"
restart: on-failure
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_ROOT_HOST: "%"
Expand All @@ -47,6 +53,7 @@ services:
soketi:
container_name: sera-soketi
image: "quay.io/soketi/soketi:latest-16-alpine"
restart: on-failure
environment:
SOKETI_DEBUG: "${SOKETI_DEBUG:-1}"
SOKETI_METRICS_SERVER_PORT: "9601"
Expand All @@ -59,12 +66,17 @@ services:
minio:
container_name: sera-minio
image: docker.io/bitnami/minio:2023
restart: on-failure
environment:
MINIO_ROOT_USER: "${MINIO_ROOT_USER:-user}"
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-password}"
MINIO_ROOT_USER: "${MINIO_ROOT_USER:-s3SeraUser}"
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-SsmHJPoqd}"
networks:
- sail
- monolith
- hosted
depends_on:
- mariadb:
condition: service_healthy

networks:
sail:
Expand All @@ -73,8 +85,3 @@ networks:
driver: bridge
hosted:
external: true
#volumes:
#sail-mariadb:
#driver: local
#sail-minio:
#driver: local
10 changes: 3 additions & 7 deletions sera-back/app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Validation\Rules;
use App\Services\CreateMinioUser;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
Expand All @@ -31,21 +31,17 @@ public function store(Request $request): Response
'role' => 'required|string|in:' . implode(',', array_keys(config('roles'))),
]);

$s3_credentials = (new CreateMinioUser())->create();
$s3_credentials['secretkey'] = Crypt::encrypt($s3_credentials['secretkey']);
$s3_credentials['accesskey'] = Crypt::encrypt($s3_credentials['accesskey']);

$user = User::create([
'email' => $request->email,
'password' => Hash::make($request->password),
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'role' => $request->role,
's3_credentials' => json_encode($s3_credentials),
's3_credentials' => json_encode([]),
]);

event(new Registered($user));

return response()->noContent();
}
}
}
3 changes: 1 addition & 2 deletions sera-back/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Illuminate\Http\Request;
use Illuminate\Validation\Rules;
use App\Services\CreateMinioUser;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
Expand Down Expand Up @@ -845,4 +844,4 @@ function getIsoList(){
return response()->json($languages);
}

}
}
10 changes: 3 additions & 7 deletions sera-back/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Database\Factories;

use Illuminate\Support\Str;
use App\Services\CreateMinioUser;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Crypt;
Expand All @@ -23,10 +22,7 @@ class UserFactory extends Factory
public function definition(): array
{
$roles = array_keys(config('roles'));
$s3_credentials = (new CreateMinioUser())->create();
// hash secret
$s3_credentials['secretkey'] = Crypt::encrypt($s3_credentials['secretkey']);
$s3_credentials['accesskey'] = Crypt::encrypt($s3_credentials['accesskey']);

return [
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
Expand All @@ -36,7 +32,7 @@ public function definition(): array
'lastname' => fake()->lastName(),
'role' => $roles[array_rand($roles)],
'avatar_filename' => fake()->boolean(50) ? '/template.jpeg' : null,
's3_credentials' => json_encode($s3_credentials),
's3_credentials' => json_encode([]),
];
}

Expand All @@ -51,4 +47,4 @@ public function unverified(): static
}
}

?>
?>
9 changes: 2 additions & 7 deletions sera-back/database/seeders/UserProdSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use App\Services\CreateMinioUser;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;

Expand All @@ -21,10 +20,6 @@ public function run(): void
return;
}

$s3_credentials = (new CreateMinioUser())->create();
$s3_credentials['secretkey'] = Crypt::encrypt($s3_credentials['secretkey']);
$s3_credentials['accesskey'] = Crypt::encrypt($s3_credentials['accesskey']);

// adapted for production and use only model and not factory
$user = \App\Models\User::firstOrCreate([
'email' => '[email protected]',
Expand All @@ -35,8 +30,8 @@ public function run(): void
'lastname' => 'Istrator',
'role' => 'cursus_director',
'avatar_filename' => 'lulu',
's3_credentials' => json_encode($s3_credentials),
's3_credentials' => json_encode([]),
]);

}
}
}

0 comments on commit 8cf095a

Please sign in to comment.