mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2025-12-24 21:27:14 +01:00
Compare commits
No commits in common. "00dac42e2c162d7e05d4152b6dfbb3cf597d9b03" and "19c995ad66667e05728f0898e619153be94a0c6f" have entirely different histories.
00dac42e2c
...
19c995ad66
11 changed files with 220 additions and 38 deletions
|
|
@ -159,7 +159,7 @@ class ParticipantsTable
|
||||||
->action(function (array $data, Participant $record) {
|
->action(function (array $data, Participant $record) {
|
||||||
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
||||||
Mail::to($record->guardian_email)
|
Mail::to($record->guardian_email)
|
||||||
->queue(new LanMail($mailContent, $record));
|
->send(new LanMail($mailContent, $record));
|
||||||
Participant::where('id', $record->id)->update(['emailed' => true]);
|
Participant::where('id', $record->id)->update(['emailed' => true]);
|
||||||
})
|
})
|
||||||
->hidden(fn($record) => !$record->emailed)
|
->hidden(fn($record) => !$record->emailed)
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class VolunteersTable
|
||||||
->action(function (array $data, Volunteer $record) {
|
->action(function (array $data, Volunteer $record) {
|
||||||
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
|
||||||
Mail::to($record->email)
|
Mail::to($record->email)
|
||||||
->queue(new LanMail($mailContent, $record));
|
->send(new LanMail($mailContent, $record));
|
||||||
Volunteer::where('id', $record->id)->update(['emailed' => true]);
|
Volunteer::where('id', $record->id)->update(['emailed' => true]);
|
||||||
})
|
})
|
||||||
->hidden(fn($record) => $record->emailed),
|
->hidden(fn($record) => $record->emailed),
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,19 @@ class ApiToken
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if ($request->header('X-API-KEY') === config('apikeys.key_1')) {
|
if ($request->api_token === config('apikeys.key_1')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_1"]);
|
$request->merge(["permission" => "key_1"]);
|
||||||
|
|
||||||
} elseif ($request->header('X-API-KEY') === config('apikeys.key_2')) {
|
} elseif ($request->api_token === config('apikeys.key_2')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_2"]);
|
$request->merge(["permission" => "key_2"]);
|
||||||
|
|
||||||
} elseif ($request->header('X-API-KEY') === config('apikeys.key_3')) {
|
} elseif ($request->api_token === config('apikeys.key_3')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_3"]);
|
$request->merge(["permission" => "key_3"]);
|
||||||
|
|
||||||
} elseif ($request->header('X-API-KEY') === config('apikeys.key_4')) {
|
} elseif ($request->api_token === config('apikeys.key_4')) {
|
||||||
|
|
||||||
$request->merge(["permission" => "key_4"]);
|
$request->merge(["permission" => "key_4"]);
|
||||||
|
|
||||||
|
|
|
||||||
54
docker-compose.dev.yml
Normal file
54
docker-compose.dev.yml
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: laravel-www
|
||||||
|
container_name: laravel-www
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/dev/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
environment:
|
||||||
|
CONTAINER_ROLE: app
|
||||||
|
networks:
|
||||||
|
- app
|
||||||
|
db:
|
||||||
|
container_name: laravel-mysql
|
||||||
|
image: "mariadb"
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
|
MYSQL_DATABASE: ${DB_DATABASE}
|
||||||
|
MYSQL_USER: ${DB_USERNAME}
|
||||||
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
||||||
|
volumes:
|
||||||
|
- "mysql:/var/lib/mysql"
|
||||||
|
networks:
|
||||||
|
- app
|
||||||
|
queue:
|
||||||
|
image: laravel-www
|
||||||
|
container_name: laravel-queue
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
- db
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
|
networks:
|
||||||
|
- app
|
||||||
|
environment:
|
||||||
|
APP_ENV: ${APP_ENV}
|
||||||
|
CONTAINER_ROLE: queue
|
||||||
|
CACHE_STORE: ${CACHE_STORE}
|
||||||
|
SESSION_DRIVER: ${SESSION_DRIVER}
|
||||||
|
QUEUE_CONNECTION: ${QUEUE_CONNECTION}
|
||||||
|
networks:
|
||||||
|
app:
|
||||||
|
driver: bridge
|
||||||
|
volumes:
|
||||||
|
mysql:
|
||||||
|
driver: local
|
||||||
|
|
@ -1,31 +1,52 @@
|
||||||
services:
|
services:
|
||||||
api:
|
web:
|
||||||
image: php
|
image: laravel-www
|
||||||
build: .
|
container_name: laravel-www
|
||||||
volumes:
|
build:
|
||||||
- .:/var/www/html
|
context: .
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
|
environment:
|
||||||
|
CONTAINER_ROLE: app
|
||||||
networks:
|
networks:
|
||||||
- app
|
- app
|
||||||
db:
|
db:
|
||||||
|
container_name: laravel-mysql
|
||||||
image: "mariadb"
|
image: "mariadb"
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: "password"
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
MYSQL_DATABASE: "vbytes_lan"
|
MYSQL_DATABASE: ${DB_DATABASE}
|
||||||
MYSQL_USER: "root"
|
MYSQL_USER: ${DB_USERNAME}
|
||||||
MYSQL_PASSWORD: "password"
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
||||||
volumes:
|
volumes:
|
||||||
- "appdb:/var/lib/mysql"
|
- "mysql:/var/lib/mysql"
|
||||||
networks:
|
networks:
|
||||||
- app
|
- app
|
||||||
|
queue:
|
||||||
|
image: laravel-www
|
||||||
|
container_name: laravel-queue
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
- db
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
|
networks:
|
||||||
|
- app
|
||||||
|
environment:
|
||||||
|
APP_ENV: ${APP_ENV}
|
||||||
|
CONTAINER_ROLE: queue
|
||||||
|
CACHE_STORE: ${CACHE_STORE}
|
||||||
|
SESSION_DRIVER: ${SESSION_DRIVER}
|
||||||
|
QUEUE_CONNECTION: ${QUEUE_CONNECTION}
|
||||||
networks:
|
networks:
|
||||||
app:
|
app:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
volumes:
|
volumes:
|
||||||
appdb:
|
mysql:
|
||||||
driver: local
|
driver: local
|
||||||
|
|
||||||
|
|
|
||||||
11
docker/apache/default.conf
Normal file
11
docker/apache/default.conf
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<VirtualHost *:80>
|
||||||
|
DocumentRoot /var/www/html/public
|
||||||
|
|
||||||
|
<Directory "/var/www/html/public">
|
||||||
|
AllowOverride all
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
FROM php:8.2-apache-buster
|
FROM php:8.2-apache
|
||||||
RUN usermod -u 1000 www-data
|
RUN usermod -u 1000 www-data
|
||||||
RUN a2enmod rewrite
|
RUN a2enmod rewrite
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y gnupg2 zlib1g-dev libzip-dev zlib1g-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libxml2-dev
|
&& apt-get install -y gnupg2 zlib1g-dev libzip-dev zlib1g-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libxml2-dev libicu-dev
|
||||||
RUN docker-php-ext-install zip mysqli pdo pdo_mysql && docker-php-ext-enable mysqli pdo pdo_mysql sodium
|
RUN docker-php-ext-install zip mysqli pdo pdo_mysql && docker-php-ext-enable mysqli pdo pdo_mysql sodium
|
||||||
RUN docker-php-ext-configure gd
|
RUN docker-php-ext-configure gd
|
||||||
RUN docker-php-ext-install gd
|
RUN docker-php-ext-install gd
|
||||||
42
docker/php/Dockerfile
Normal file
42
docker/php/Dockerfile
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
FROM php:8.4-apache
|
||||||
|
|
||||||
|
|
||||||
|
## Copy the entire Laravel application code into the container
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
# Apache vhost & entry script
|
||||||
|
COPY docker/apache/default.conf /etc/apache2/sites-available/000-default.conf
|
||||||
|
COPY docker/scripts/start.sh /usr/local/bin/start
|
||||||
|
|
||||||
|
|
||||||
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
|
&& chmod u+x /usr/local/bin/start \
|
||||||
|
&& a2enmod rewrite
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y gnupg2 zlib1g-dev libzip-dev zlib1g-dev libicu-dev libpng-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libxml2-dev curl unzip
|
||||||
|
RUN docker-php-ext-install zip mysqli pdo pdo_mysql && docker-php-ext-enable mysqli pdo pdo_mysql sodium
|
||||||
|
RUN docker-php-ext-configure gd
|
||||||
|
RUN docker-php-ext-install gd
|
||||||
|
RUN docker-php-ext-configure intl
|
||||||
|
RUN docker-php-ext-install intl
|
||||||
|
|
||||||
|
# Install Node.js and build tools
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
# Add Composer
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||||
|
&& composer install --no-interaction --no-progress
|
||||||
|
|
||||||
|
# Install Node.js dependencies and build assets
|
||||||
|
RUN npm install && npm run build
|
||||||
|
|
||||||
|
RUN chown -R www-data:www-data /var/www/html
|
||||||
|
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
CMD ["/usr/local/bin/start"]
|
||||||
54
docker/scripts/start.sh
Normal file
54
docker/scripts/start.sh
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
role=${CONTAINER_ROLE:-app}
|
||||||
|
env=${APP_ENV:-production}
|
||||||
|
|
||||||
|
chown -R www-data:www-data /var/www/html
|
||||||
|
chmod -R 775 /var/www/html/storage
|
||||||
|
chmod -R 775 /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
|
if [ ! -d "/var/www/html/vendor" ]; then
|
||||||
|
composer install --no-interaction --no-progress
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/var/www/html/.env" ]; then
|
||||||
|
if ! grep -q "^APP_KEY=" .env || grep -q "^APP_KEY=$" .env; then
|
||||||
|
php artisan key:generate
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#if [ "${RUN_MIGRATIONS:-false}" = "true" ]; then
|
||||||
|
#php artisan migrate --force
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if [ "$env" != "local" ]; then
|
||||||
|
echo "Caching configuration..."
|
||||||
|
(cd /var/www/html &&
|
||||||
|
php artisan optimize &&
|
||||||
|
php artisan filament:optimize &&
|
||||||
|
php artisan config:cache &&
|
||||||
|
php artisan route:cache &&
|
||||||
|
php artisan view:cache)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$role" = "app" ]; then
|
||||||
|
|
||||||
|
exec apache2-foreground
|
||||||
|
|
||||||
|
elif [ "$role" = "queue" ]; then
|
||||||
|
|
||||||
|
echo "Running the queue..."
|
||||||
|
php /var/www/html/artisan queue:work --verbose --tries=3 --timeout=90
|
||||||
|
|
||||||
|
elif [ "$role" = "scheduler" ]; then
|
||||||
|
|
||||||
|
echo "Scheduler role"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Could not match the container role \"$role\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
## Endpoints
|
## Endpoints
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>GET</code> <code><b>/data</b></code></summary>
|
<summary><code>GET</code> <code><b>/data/{api_token}</b></code></summary>
|
||||||
|
|
||||||
##### Headers
|
##### Parameters
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|------------|----------------|--------------------------------------------------------------|
|
> |-------------|------------|----------------|--------------------------------------------------------------|
|
||||||
> | `x-api-key` | required | string | Api key with permission |
|
> | `api_token` | required | string | Api key with permission |
|
||||||
|
|
||||||
|
|
||||||
##### Responses
|
##### Responses
|
||||||
|
|
@ -124,13 +124,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>GET</code> <code><b>/version</b></code></summary>
|
<summary><code>GET</code> <code><b>/version/{api_token}</b></code></summary>
|
||||||
|
|
||||||
##### Headers
|
##### Parameters
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|------------|----------------|--------------------------------------------------------------|
|
> |-------------|------------|----------------|--------------------------------------------------------------|
|
||||||
> | `x-api-key` | required | string | Api key with permission |
|
> | `api_token` | required | string | Api key with permission |
|
||||||
|
|
||||||
##### Responses
|
##### Responses
|
||||||
|
|
||||||
|
|
@ -181,13 +181,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>POST</code> <code><b>/participant</b></code></summary>
|
<summary><code>POST</code> <code><b>/participant/{api_token}</b></code></summary>
|
||||||
|
|
||||||
##### Headers
|
##### Parameters
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
||||||
> | `x-api-key` | required | string | Api key with permission |
|
> | `api_token` | required | string | Api key with permission |
|
||||||
|
|
||||||
##### Body data
|
##### Body data
|
||||||
|
|
||||||
|
|
@ -237,13 +237,13 @@
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><code>POST</code> <code><b>/volunteer</b></code></summary>
|
<summary><code>POST</code> <code><b>/volunteer/{api_token}</b></code></summary>
|
||||||
|
|
||||||
##### Headers
|
##### Parameters
|
||||||
|
|
||||||
> | name | type | data type | description |
|
> | name | type | data type | description |
|
||||||
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
> |-------------|-----------|-------------------------|-----------------------------------------------------------------------|
|
||||||
> | `x-api-key` | required | string | Api key with permission |
|
> | `api_token` | required | string | Api key with permission |
|
||||||
|
|
||||||
|
|
||||||
##### Body data
|
##### Body data
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ use App\Http\Controllers\VersionController;
|
||||||
// return $request->user();
|
// return $request->user();
|
||||||
//})->middleware('auth:sanctum');
|
//})->middleware('auth:sanctum');
|
||||||
|
|
||||||
Route::get('/data', [ParticipantController::class, 'index'] )->middleware([ApiToken::class]);
|
Route::get('/data/{api_token}', [ParticipantController::class, 'index'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::get('/version', [VersionController::class, 'index'] )->middleware([ApiToken::class]);
|
Route::get('/version/{api_token}', [VersionController::class, 'index'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::post('/participant', [ParticipantController::class, 'store'] )->middleware([ApiToken::class]);
|
Route::post('/participant/{api_token}', [ParticipantController::class, 'store'] )->middleware([ApiToken::class]);
|
||||||
|
|
||||||
Route::post('/volunteer', [VolunteerController::class, 'store'] )->middleware([ApiToken::class]);
|
Route::post('/volunteer/{api_token}', [VolunteerController::class, 'store'] )->middleware([ApiToken::class]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue