41 Commits

Author SHA1 Message Date
885ad069d3 feat: add Docker docs 2025-12-05 12:18:29 +01:00
cd2afee8fc fix: add missing backend and frontend domain variables in .env.example 2025-12-04 23:52:24 +01:00
af5dbc2767 fix: update environment variables for frontend and backend URLs in compose file 2025-12-04 23:50:10 +01:00
430100f62d fix: remove non-functioning sanctum module config 2025-12-04 23:49:46 +01:00
1224d2057b fix: trust all proxies 2025-12-04 22:52:23 +01:00
77e099a16e fix: add runtime configuration for Sanctum base URL and origin 2025-12-04 21:06:37 +01:00
0da6157255 fix: missing https:// in docker environment example 2025-12-04 21:05:55 +01:00
f0ac4e0cdf fix: add APP_KEY to .env.example for configuration 2025-12-04 20:40:06 +01:00
679b6ab913 fix: make APP_KEY configurable with environment variable 2025-12-04 20:39:13 +01:00
a93c8d236a fix: add .env to .gitignore 2025-12-04 20:30:31 +01:00
92782bfff3 fix: fix incorrect environment variable name for frontend service 2025-12-04 20:28:50 +01:00
d052e464b2 fix: update environment variables in docker-compose for better configurability 2025-12-04 20:28:19 +01:00
962ae2d0d3 fix: remove unused runtime config 2025-12-04 20:27:55 +01:00
72bca8876e refactor: remove unused Caddyfile configuration 2025-12-04 20:11:52 +01:00
380cf51b77 Merge branch 'feature/docker-frankenphp' into feature/docker 2025-12-04 20:08:36 +01:00
a6164cdcf0 Merge branch 'develop' into feature/docker 2025-12-04 20:05:28 +01:00
43b056f412 fix: broken cypress tests due to new internship list view
Some checks failed
Cypress E2E Tests / cypress-tests (push) Has been cancelled
2025-12-04 12:46:10 +01:00
cbfd4f1b68 refactor: remove unused NUXT_HOST and NUXT_PORT environment variables 2025-12-04 12:17:13 +01:00
be284c061e refactor: add sample domain and environment variables 2025-12-04 12:16:09 +01:00
e62fe4c443 feat: make backend image default to port 80 2025-12-04 12:10:48 +01:00
Veronika Fehérvíziová
b9be4a2e6c fix: allow changing internship status when denied by admin 2025-12-02 22:53:01 +01:00
Veronika Fehérvíziová
06e6e59a18 feat: notify company of internship status updates 2025-12-02 22:52:22 +01:00
Veronika Fehérvíziová
a9ac8a2735 refactor: rename contact method to contactPerson to avoid default conflicts 2025-12-02 22:51:53 +01:00
Veronika Fehérvíziová
01aae85efc refactor: update email template for internship status updates 2025-12-02 22:51:29 +01:00
Veronika Fehérvíziová
b95cdb070d Revert "refactor: increase the number of users and companies in seeder"
This reverts commit 1d2016c011.
2025-12-02 20:40:10 +01:00
Veronika Fehérvíziová
e64b6c2eca feat: add dynamic max year of study based on selected program in registration form 2025-12-02 20:32:31 +01:00
Veronika Fehérvíziová
4a5a4f990c feat: improve phone input validation and update study program options in registration form 2025-12-02 20:28:17 +01:00
Veronika Fehérvíziová
2b31c1d2ad feat: enhance phone input validation in registration form 2025-12-02 20:27:59 +01:00
Veronika Fehérvíziová
b612c0f873 feat: add validation rules for internship filter inputs 2025-12-02 20:26:14 +01:00
Veronika Fehérvíziová
9de30a7df1 refactor: improve address generation in Company and Student data factories 2025-12-02 19:30:54 +01:00
Veronika Fehérvíziová
1d2016c011 refactor: increase the number of users and companies in seeder 2025-12-02 19:30:42 +01:00
Veronika Fehérvíziová
687018e0fe rename and translate CLI command for admin create 2025-12-02 19:10:13 +01:00
Veronika Fehérvíziová
6902eadef5 refactor: rename CLI for creating admin 2025-12-02 19:00:04 +01:00
187b56b464 feat: build custom image for backend 2025-12-02 16:19:51 +01:00
c99017623b feat: add docker-compose stack with FrankenPHP 2025-12-02 15:32:23 +01:00
b1c26b762a feat: setup Dockerfile for frontend 2025-12-02 15:31:49 +01:00
77c4164dcb refactor: update docker-compose.yml to define service names and improve structure 2025-10-31 17:46:31 +01:00
550f07df79 fix: update php_fastcgi service reference in Caddyfile 2025-10-31 17:46:17 +01:00
4714cc7892 fix: correct CMD syntax in Dockerfile for frontend server 2025-10-31 17:45:47 +01:00
042cdcdb3a fix: update Sanctum base URL and origin for local development 2025-10-31 17:45:27 +01:00
79a8c4f229 feat: add basic Docker configuration for backend and frontend services 2025-10-28 12:28:11 +01:00
25 changed files with 529 additions and 123 deletions

9
backend/.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
.git
.env
storage/logs/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
bootstrap/cache/*
.phpunit.result.cache
vendor/*

18
backend/Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
FROM dunglas/frankenphp:1.10-php8.4-bookworm
RUN install-php-extensions \
pdo_mysql \
gd \
intl \
zip \
opcache
COPY . /app
WORKDIR /app
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install --no-dev --optimize-autoloader
ENV SERVER_NAME=:80

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Hash;
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new admin user';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('=== Create Admin ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('First name');
$lastName = $this->ask('Last name');
$email = $this->ask('E-mail');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('A user with the same email already exists.');
return 1;
}
$password = $this->secret('Enter password');
$phone = $this->ask('Enter phone number');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'password' => Hash::make($password),
'active' => true,
'role' => 'ADMIN',
'phone' => $phone,
]);
$this->info("\n Admin {$user->first_name} {$user->last_name} created.");
return 0;
}
}

View File

@@ -1,59 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class CreateGarant extends Command
{
/**
* Názov CLI príkazu.
*/
protected $signature = 'user:create-garant';
/**
* Popis príkazu.
*/
protected $description = 'Interaktívne vytvorí nového používateľa s rolou admin (garant)';
/**
* Spustenie príkazu.
* php artisan user:create-garant
*/
public function handle()
{
$this->info('=== Vytvorenie garanta (admin) ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('Zadaj krstné meno');
$lastName = $this->ask('Zadaj priezvisko');
$email = $this->ask('Zadaj email');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('Používateľ s týmto emailom už existuje.');
return 1;
}
$password = $this->secret('Zadaj heslo (nebude sa zobrazovať)');
$phone = $this->ask('Zadaj telefón ');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'phone' => $phone,
'role' => 'ADMIN',
'password' => Hash::make($password),
]);
$this->info("\n Garant {$user->first_name} {$user->last_name} bol úspešne vytvorený s rolou ADMIN.");
$this->info("Email: {$user->email}");
return 0;
}
}

View File

@@ -123,17 +123,30 @@ class InternshipStatusDataController extends Controller
'modified_by' => $user->id
]);
// mail študentovi
Mail::to($internship->student)
->sendNow(new InternshipStatusUpdated(
$internship,
$user->name,
$internship->student->name,
$internship->company->name,
$internshipStatus->status,
$request->enum('status', InternshipStatus::class),
$request->note
$newStatus->status,
$request->note,
$user,
recipiantIsStudent: true,
));
// ak zmenu nevykonala firma, posleme mail aj firme
if ($user->id !== $internship->company->contactPerson->id) {
Mail::to($internship->company->contactPerson->email)
->sendNow(new InternshipStatusUpdated(
$internship,
$internshipStatus->status,
$newStatus->status,
$request->note,
$user,
recipiantIsStudent: false,
));
}
$newStatus->save();
return response()->noContent();
}

View File

@@ -4,6 +4,7 @@ namespace App\Mail;
use App\Enums\InternshipStatus;
use App\Models\Internship;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
@@ -15,25 +16,23 @@ class InternshipStatusUpdated extends Mailable
use Queueable, SerializesModels;
private Internship $internship;
private string $changedByName;
private string $studentName;
private string $companyName;
private InternshipStatus $oldStatus;
private InternshipStatus $newStatus;
private string $note;
private User $changedBy;
private bool $recipiantIsStudent;
/**
* Create a new message instance.
*/
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note)
public function __construct(Internship $internship, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note, User $changedBy, bool $recipiantIsStudent)
{
$this->internship = $internship;
$this->changedByName = $changedByName;
$this->studentName = $studentName;
$this->companyName = $companyName;
$this->oldStatus = $oldStatus;
$this->newStatus = $newStatus;
$this->note = $note;
$this->changedBy = $changedBy;
$this->recipiantIsStudent = $recipiantIsStudent;
}
/**
@@ -55,12 +54,11 @@ class InternshipStatusUpdated extends Mailable
view: 'mail.internship.status_updated',
with: [
"internship" => $this->internship,
"changedByName" => $this->changedByName,
"studentName" => $this->studentName,
"companyName" => $this->companyName,
"oldStatus" => $this->prettyStatus($this->oldStatus->value),
"newStatus" => $this->prettyStatus($this->newStatus->value),
"note" => $this->note,
"recipiantIsStudent" => $this->recipiantIsStudent,
"changedBy" => $this->changedBy,
]
);
}

View File

@@ -44,7 +44,7 @@ class Company extends Model
/**
* Get the contact person (user) for the company.
*/
public function contact()
public function contactPerson()
{
return $this->belongsTo(User::class, 'contact');
}

View File

@@ -107,6 +107,10 @@ class Internship extends Model
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
// prax bola zamietnutá garantom a ide ju meniť garant
$current_status === InternshipStatus::DENIED_BY_ADMIN && $userRole === "ADMIN"
=> ['CONFIRMED_BY_COMPANY', 'CONFIRMED_BY_ADMIN', 'DENIED_BY_COMPANY'],
// prax bola obhájená a ide ju meniť admin
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
=> ['NOT_DEFENDED'],

View File

@@ -6,12 +6,14 @@ use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies('*');
$middleware->api(prepend: [
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
]);

View File

@@ -18,7 +18,7 @@ class CompanyFactory extends Factory
{
return [
'name' => fake()->company(),
'address' => fake()->address(),
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'ico' => fake()->numberBetween(111111, 999999),
'contact' => 0,
'hiring' => fake()->boolean(),

View File

@@ -18,7 +18,7 @@ class StudentDataFactory extends Factory
{
return [
'user_id' => 0,
'address' => fake()->address(),
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'personal_email' => fake()->safeEmail(),
'study_field' => fake()->randomElement(["AI22m", "AI22b"]),
];

View File

@@ -0,0 +1,14 @@
#!/bin/bash
function exit_container_SIGTERM(){
echo "Caught SIGTERM"
exit 0
}
trap exit_container_SIGTERM SIGTERM
echo "Setting /app/public ownership..."
chgrp -R 33 /app
chown -hR 33:33 /app
echo "Starting PHP-FPM..."
php-fpm -F & wait

View File

@@ -1,14 +1,21 @@
@include("parts.header")
<p>Vážená/ý {{ $studentName }},</p>
<p>stav vašej praxe vo firme {{ $companyName }} bola aktualizovaná zo stavu "{{ $oldStatus }}" na
"{{ $newStatus }}".</p>
<p>Zmenu vykonal <em>{{ $changedByName }}</em>.</p>
<br />
@if($recipiantIsStudent)
<p>Vážená/ý {{ $internship->student->name }},</p>
@else
<p>Vážená/ý {{ $internship->company->contactPerson->name }},</p>
@endif
<p>oznamujeme Vás o zmene praxe:</p>
@if(!$recipiantIsStudent)
<p>Študent: <em>{{ $internship->student->name }} ({{ $internship->student->email }},
{{ $internship->student->phone }})</em></p>
@endif
<p>Stav: <em>{{ $oldStatus }}</em> <strong>-></strong> <em>{{ $newStatus }}</em></p>
<p>Poznámka: <em>{{ $note }}</em>.</p>
<p>Zmenu vykonal <em>{{ $changedBy->name }}</em>.</p>
<br />
<p>s pozdravom</p>
<p>S pozdravom.</p>
<p>Systém ISOP UKF</p>
@include("parts.footer")

6
docker/.env.example Normal file
View File

@@ -0,0 +1,6 @@
BACKEND_URL=https://backend.example.com
FRONTEND_URL=https://example.com
BACKEND_DOMAIN=backend.example.com
FRONTEND_DOMAIN=example.com
SESSION_DOMAIN=.example.com
APP_KEY=SOME-KEY

2
docker/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
mariadb_data/
.env

199
docker/README.md Normal file
View File

@@ -0,0 +1,199 @@
# Docker
Hostovanie s Dockerom je možné použitím `docker-compose.yml`. Definuje 3 služby:
- Frontend
- `node:22-alpine`
- Build aplikácie prebieha cez [pnpm](https://pnpm.io/).
- Backend
- `dunglas/frankenphp:1.10-php8.4-bookworm`
- PHP verzia `8.4`
- Extensions:
- `pdo_mysql`
- `gd`
- `intl`
- `zip`
- `opcache`
- Aplikácia je servovaná pomocou [Caddy](https://caddyserver.com/)
- Databáza
- `mariadb:11.8.2-noble`
Každá služba má `healthcheck` a `depends_on` na zabezpečenie vhodného spustenia a kontroly funkčnosti.
> ⚠️ Tento setup je určený pre produkčné nasadenie a vyžaduje manuálne nastavenie reverzných proxy na zabezpečenie pomocou HTTPS. Pre lokálne testovanie (neodporúčané) je nutné ručne nastaviť DNS záznamy (napr. cez `/etc/hosts`).
## Prerekvizity
### Softvérové požiadavky
Je vyžadovaný iba Docker s Docker Compose. V novších verzách Dockeru je už Compose zabudovaný.
Testované s:
| **Verzia** | **OS** |
|-------------------|--------------------|
| 28.5.2/ecc694264d | linux/arch-cachyos |
| 29.1.1/0aedba5 | linux/debian-lxc |
Ako reverzné proxy môžete použiť napríklad [Caddy](https://caddyserver.com/), [Traefik](https://traefik.io/), [Nginx](https://nginx.org/) alebo [Cloudflare Tunely](https://www.cloudflare.com/products/tunnel/). Odporúčame však Caddy kvôli jednoduchej konfigurácii a automatickému získavaniu SSL certifikátov cez Let's Encrypt, prípadne Cloudflare Tunely pre jednoduché nastavenie bez potreby spravovať DNS záznamy a certifikáty.
### Hardvérové požiadavky (pre build)
| | Minimálne | Odporúčané |
|-----|-----------|------------|
| RAM | 2GB | 4GB |
| CPU | 2 | 4 |
Ak máte iba 2GB RAM, odporúčame nastaviť min 2GB swap pamäte, aby build prebehol úspešne. Prípadne môžete obmedziť počet paralelných buildov.
## Základná inštalácia a nastavenie
### Stiahnutie projektu a buildovanie
Projekt si najprv stiahnite do vami zvoleného priečinka:
```sh
git clone https://github.com/isop-ukf/isop-app.git
```
Podľa potreby prejdite na požadovanú branchu:
```sh
cd isop-app
git checkout [branch]
```
Prejdite do adresára `docker`:
```sh
cd docker
```
Spustite build nasledovným príkazom:
```sh
docker compose build
```
> Počet paralelných buildov môžete obmedziť pomocou `--parallel N` (pred `build`), kde N je počet súčasne bežiacich buildov.
> ⏱️ Build trvá približne 2 min.
> ⚠️ Kvôli kompilácii PHP modulov počas buildu dôjde k zvýšenému využitiu CPU a RAM.
### Nastavenie prostredia
Pred prvým spustením je potrebné vytvoriť súbor `.env` na základe šablóny `.env.example`:
```sh
cp .env.example .env
```
- `BACKEND_URL`: URL adresa backendu **vrátane** protokolu (a prípade portu)
- `FRONTEND_URL`: URL adresa frontendu **vrátane** protokolu (a prípade portu)
- `BACKEND_DOMAIN`: Doména pre backend **bez** protokolu a portu
- `FRONTEND_DOMAIN`: Doména pre frontend **bez** protokolu a portu
- `SESSION_DOMAIN`: Doména pre session cookies, prípadne aj s bodkou na začiatku pre zdieľanie medzi subdoménami
- `APP_KEY`: Aplikačný kľúč pre šifrovanie (postup nižšie)
Príklad `.env` súboru:
```env
BACKEND_URL=https://backend.myapp.com
FRONTEND_URL=https://myapp.com
BACKEND_DOMAIN=backend.myapp.com
FRONTEND_DOMAIN=myapp.com
SESSION_DOMAIN=.myapp.com
APP_KEY=base64:Xxx00XX+X/ABC+AABBCCDDEEFFGGHHXYZ0+00000000=
```
### Vygenerovanie aplikačného kľúča
Aplikačný kľúč môžete vygenerovať pomocou nasledujúceho príkazu:
```sh
docker compose run --rm --no-deps isop-backend php artisan key:generate --show
```
> ⚠️ Odporúčame zmazať vytvorený kontajner po vygenerovaní kľúča.
> ```sh
> docker compose down
> ```
### Spustenie migrácií
Pred prvým spustením aplikácie je potrebné spustiť databázové migrácie príkazmi:
```sh
docker compose up -d isop-backend isop-database
docker compose exec isop-backend php artisan migrate:fresh
docker compose down
```
## Spustenie aplikácie
Aplikáciu spustíte príkazom:
```sh
docker compose up -d
```
Logy môžete sledovať pomocou:
```sh
docker compose logs -f
```
## Zastavenie aplikácie
Aplikáciu zastavíte príkazom:
```sh
docker compose down
```
## Aktualizácia aplikácie
Pre aktualizáciu aplikácie postupujte nasledovne:
1. Stiahnite najnovšie zmeny z repozitára:
```sh
git pull
```
2. Zastavte bežiacu aplikáciu:
```sh
docker compose down
```
3. Znovu postavte kontajnery:
```sh
docker compose build
```
4. Spustite aplikáciu:
```sh
docker compose up -d
```
## Záloha a obnova dát
Dáta aplikácie sú uložené v databáze, ktorú je možné zálohovať a obnoviť pomocou štandardných nástrojov pre MariaDB/MySQL, ako je `mysqldump` a `mysql`, alebo pomcou archivácie dátového adresára databázy.
Príklad na zálohovanie databázy:
```sh
tar czvf db-backup.tar.gz mariadb-data/
```
> ⚠️ Odporúčame použiť `tar` na archiváciu dátového adresára, aby ste zachovali správne oprávnenia.
## Zabezpečenie
## Cloudflare Tunnel
Inštaláciu a základné nastavenie nájdete v [dokumentácii Cloudflare](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/). Je potrebné vytvoriť 2 tunely - jeden pre frontend a druhý pre backend.
Na spustenie tunela môžete vytvoriť samostatný Docker Compose súbor, napríklad:
```yaml
services:
tunnel:
image: cloudflare/cloudflared:2025.11.1
container_name: cloudflared-tunnel
restart: unless-stopped
network_mode: "host"
command: tunnel run
environment:
- TUNNEL_TOKEN=TOKEN-XYZ
```
Následne nastavne DNS záznamy vo vašom Cloudflare účte, aby smerovali na tunely, napríklad:
- `myapp.com` -> `localhost:80`
- `backend.myapp.com` -> `localhost:8111`
## Caddy
Inštaláciu a základné nastavenie nájdete v [dokumentácii Caddy](https://caddyserver.com/docs/).
Príklad konfigurácie:
```
backend.myapp.com {
reverse_proxy localhost:8111
}
myapp.com {
reverse_proxy localhost:80
}
```

83
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,83 @@
services:
isop-frontend:
container_name: isop-frontend
build:
context: ../frontend
dockerfile: Dockerfile
restart: unless-stopped
environment:
NUXT_PUBLIC_SANCTUM_BASE_URL: ${BACKEND_URL:-https://backend.example.com}
ports:
- 80:80
depends_on:
- isop-backend
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost"]
start_period: 10s
interval: 1m
timeout: 5s
retries: 5
isop-backend:
container_name: isop-backend
build:
context: ../backend
dockerfile: Dockerfile
restart: unless-stopped
environment:
APP_NAME: ISOP
APP_ENV: production
APP_KEY: ${APP_KEY:-SOME-KEY}
APP_DEBUG: false
APP_URL: ${BACKEND_URL:-https://example.com}
FRONTEND_URL: ${FRONTEND_URL:-https://example.com}
SANCTUM_STATEFUL_DOMAINS: ${BACKEND_DOMAIN:-https://backend.example.com},${FRONTEND_DOMAIN:-https://example.com}
SESSION_DOMAIN: ${SESSION_DOMAIN:-.example.com} # Note the first dot
APP_LOCALE: sk
APP_FALLBACK_LOCALE: en_US
MAIL_MAILER: smtp
MAIL_HOST: smtp.example.com
MAIL_PORT: 2525
MAIL_USERNAME: username
MAIL_PASSWORD: password
MAIL_FROM_ADDRESS: "noreply@example.com"
MAIL_FROM_NAME: "ISOP"
DB_CONNECTION: mariadb
DB_HOST: isop-database
DB_PORT: 3306
DB_DATABASE: isop
DB_USERNAME: root
DB_PASSWORD: admin
ports:
- 8111:80
depends_on:
isop-database:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/api"]
start_period: 10s
interval: 1m
timeout: 5s
retries: 5
isop-database:
container_name: isop-database
image: mariadb:11.8.2-noble
restart: unless-stopped
cap_add:
# Allow memory binding
- SYS_NICE
environment:
MARIADB_DATABASE: "isop"
MARIADB_ROOT_PASSWORD: "admin"
volumes:
- ./mariadb_data:/var/lib/mysql
healthcheck:
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
start_period: 10s
interval: 1m
timeout: 5s
retries: 3

8
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.nuxt/
.output/
.env*
node_modules/
cypress/
cypress.config.ts
package-lock.json
*.md

37
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
# Build Stage 1
FROM node:22-alpine AS build
WORKDIR /app
RUN corepack enable
# Copy package.json and your lockfile
COPY package.json ./
# Install dependencies
RUN pnpm i
# Copy the entire project
COPY . ./
# Prepare Nuxt (generates .nuxt with type definitions and auto-imports)
RUN pnpm run postinstall
# Build the project
RUN pnpm run build
# Build Stage 2
FROM node:22-alpine
WORKDIR /app
# Only `.output` folder is needed from the build stage
COPY --from=build /app/.output/ ./
# Change the port and host
ENV PORT=80
ENV HOST=0.0.0.0
EXPOSE 80
CMD ["node", "/app/server/index.mjs"]

View File

@@ -25,6 +25,11 @@ const totalItems = ref(0);
const deleteConfirmDialog = ref(false);
const internshipToDelete = ref<Internship | null>(null);
const rules = {
minFilterLen: (v: string) => (v.length >= 3) || 'Min. 3 znaky',
minYear: (v: number | null) => (v === null ? true : v >= 1000) || 'Min. 4-ciferné číslo'
};
const allHeaders = [
{ title: "Študent", key: "student.name", sortable: false },
{ title: "Firma", key: "company.name", sortable: false },
@@ -99,16 +104,20 @@ async function confirmDeletion(confirm: boolean) {
<v-row>
<v-col cols="12" md="3">
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact" />
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact"
:rules="[rules.minYear]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'company'">
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact" />
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact" />
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.student" label="Študent" clearable density="compact" />
<v-text-field v-model="filters.student" label="Študent" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col>
</v-row>
@@ -127,13 +136,13 @@ async function confirmDeletion(confirm: boolean) {
<v-tooltip text="Editovať">
<template #activator="{ props }">
<v-btn icon="mdi-pencil" size="small" variant="text"
:to="`/dashboard/${mode}/internships/edit/${item.id}`" />
:to="`/dashboard/${mode}/internships/edit/${item.id}`" class="internship-edit-btn" />
</template>
</v-tooltip>
<v-tooltip text="Vymazať" v-if="mode === 'admin'">
<template #activator="{ props }">
<v-btn icon="mdi-delete" size="small" variant="text" color="error"
@click="() => openDeleteDialog(item)" />
@click="() => openDeleteDialog(item)" class="internship-delete-btn" />
</template>
</v-tooltip>
</template>

View File

@@ -19,7 +19,8 @@ useSeoMeta({
const rules = {
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
phone: (v: string) => (!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
phone: (v: string) =>
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
};
@@ -101,8 +102,8 @@ async function handleRegistration() {
density="comfortable" />
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined"
density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
variant="outlined" density="comfortable" />
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -23,11 +23,14 @@ const rules = {
personal_email: (v: string) =>
/.+@.+\..+/.test(v) || 'Zadajte platný osobný email',
phone: (v: string) =>
(!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
};
const programs = [
'Aplikovaná informatika',
{ title: 'Aplikovaná informatika, Bc. (AI22b)', value: 'AI22b' },
{ title: 'Aplikovaná informatika, Bc. (AI15b)', value: 'AI15b' },
{ title: 'Aplikovaná informatika, Mgr. (AI22m)', value: 'AI22m' },
{ title: 'Aplikovaná informatika, Mgr. (AI15m)', value: 'AI15m' },
];
const isValid = ref(false);
@@ -38,10 +41,11 @@ const form = ref({
studentEmail: '',
personalEmail: '',
phone: '',
studyProgram: programs[0] as string,
studyProgram: programs[0]!.value,
year_of_study: 1,
consent: false,
});
const maxYearOfStudy = ref(0);
const loading = ref(false);
const error = ref(null as null | string);
@@ -80,6 +84,10 @@ async function handleRegistration() {
loading.value = false;
}
}
watch(form, (newForm) => {
maxYearOfStudy.value = newForm.studyProgram.slice(-1) === 'b' ? 3 : 2;
}, { deep: true, immediate: true });
</script>
<template>
@@ -109,14 +117,14 @@ async function handleRegistration() {
<v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]"
label="Alternatívny email:" variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]" label="Telefón:"
variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]"
label="Telefón (s predvoľbou):" variant="outlined" density="comfortable" />
<v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]"
label="Študijný odbor:" variant="outlined" density="comfortable" />
<v-number-input control-variant="split" v-model="form.year_of_study" :rules="[rules.required]"
label="Ročník:" :min="1" :max="5"></v-number-input>
label="Ročník:" :min="1" :max="maxYearOfStudy"></v-number-input>
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -12,6 +12,7 @@ describe('Admin Student Document Downloads', () => {
cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
})
it('should be able to generate and download the default proof', () => {
@@ -24,13 +25,12 @@ describe('Admin Student Document Downloads', () => {
})
cy.get('@randomRow').within(() => {
cy.get('td').contains('Editovať').click()
cy.get('td').get('.internship-edit-btn').click()
})
})
cy.url().should('include', '/dashboard/admin/internships/edit/')
const downloadsFolder = Cypress.config("downloadsFolder");
cy.contains('Stiahnuť originálnu zmluvu').click()
cy.wait(2000)
})

View File

@@ -12,6 +12,7 @@ describe('Admin Internship CRUD', () => {
cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
})
it('should load the list of internships in a proper format', () => {
@@ -64,28 +65,15 @@ describe('Admin Internship CRUD', () => {
})
})
// Ešte nie je implementované mazanie
/*it('should be able to delete an internship', () => {
let initialRowCount = 0
cy.get('table tbody tr').its('length').then((count) => {
initialRowCount = count
})
it('should be able to delete an internship', () => {
cy.get('table tbody tr').first().within(() => {
cy.contains('Vymazať').click()
cy.get('.internship-delete-btn').click()
})
cy.contains("Potvrdiť vymazanie").parent().should('be.visible')
cy.contains("Potvrdiť vymazanie").parent().contains("Vymazať").click()
cy.contains("Potvrdiť vymazanie").parent().contains("Áno").click()
cy.contains("Potvrdiť vymazanie").should('not.exist')
cy.wait(1000)
cy.get('table tbody tr').its('length').then((count) => {
expect(count).to.be.eq(initialRowCount - 1)
})
})*/
// TODO: Edit praxe
})
})

View File

@@ -22,8 +22,6 @@ export default defineNuxtConfig({
},
sanctum: {
baseUrl: 'http://localhost:8000',
origin: 'http://localhost:3000',
redirect: {
onLogin: '/dashboard',
onLogout: "/",