Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/storage/logs/*
/storage/framework/cache/data/*
/storage/framework/sessions/*
/storage/framework/views/*
/storage/app/ai-corpus/*
/vendor
.env
.env.*
!.env.example
vendor/
node_modules/
storage/logs/*
storage/framework/cache/data/*
storage/framework/sessions/*
storage/framework/views/*
storage/app/ai-corpus/*
tests/
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.git/
.github/
docker-compose.yml
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
QR_HMAC_SECRET=
APP_DEBUG=true
APP_URL=http://localhost

Expand Down
72 changes: 55 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
# Build stage for assets
FROM node:20-alpine AS builder
# Stage 1: Install Composer dependencies
FROM composer:2 AS vendor

WORKDIR /tmp
WORKDIR /app

COPY composer.json composer.lock ./

RUN composer install \
--no-dev \
--no-interaction \
--no-progress \
--no-scripts \
--prefer-dist \
--optimize-autoloader \
--ignore-platform-req=ext-gd \
--ignore-platform-req=ext-imagick

# Stage 2: Build frontend assets
FROM node:20-alpine AS frontend

WORKDIR /app

COPY package*.json ./
RUN npm ci

# Copy full application and vendor so Tailwind can scan MaryUI and Blade components
COPY . .
COPY --from=vendor /app/vendor ./vendor

RUN npm run build

# Production stage
# Stage 3: Production runtime
FROM php:8.4-fpm-alpine

# Install nginx, supervisor, and system dependencies
Expand All @@ -22,29 +42,49 @@ RUN apk add --no-cache \
freetype \
libjpeg-turbo \
libpng \
icu-libs \
imagemagick \
imagemagick-libs \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
postgresql-dev \
icu-dev \
imagemagick-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
bcmath \
gd \
intl \
opcache \
pcntl \
pdo_pgsql \
pgsql \
zip \
&& printf "\n" | pecl install imagick \
&& docker-php-ext-enable imagick \
&& apk del .build-deps \
&& rm -rf /tmp/pear

# Copy composer from the official composer image
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy composer binary
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

# Copy application source code
COPY . /var/www/html
COPY --from=builder /tmp/public/build /var/www/html/public/build

# Copy vendor dependencies from vendor stage
COPY --from=vendor /app/vendor /var/www/html/vendor

# Copy compiled frontend assets from frontend stage
COPY --from=frontend /app/public/build /var/www/html/public/build

# Generate optimized autoload with app classes
RUN composer dump-autoload --optimize --no-dev --working-dir=/var/www/html

# Setup configuration
COPY Docker/nginx.conf /etc/nginx/http.d/default.conf
Expand All @@ -55,16 +95,14 @@ COPY Docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN chown -R nginx:nginx /var/www/html/storage /var/www/html/bootstrap/cache \
&& chmod +x /var/www/html/Docker/start.sh

RUN composer install --no-dev --no-interaction --optimize-autoloader --working-dir=/var/www/html

ENV WEBROOT /var/www/html/public
ENV PHP_ERRORS_STDERR 1
ENV RUN_SCRIPTS 1
ENV REAL_IP_HEADER 1
ENV APP_ENV production
ENV APP_DEBUG false
ENV LOG_CHANNEL stderr
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV WEBROOT=/var/www/html/public
ENV PHP_ERRORS_STDERR=1
ENV RUN_SCRIPTS=1
ENV REAL_IP_HEADER=1
ENV APP_ENV=production
ENV APP_DEBUG=false
ENV LOG_CHANNEL=stderr
ENV COMPOSER_ALLOW_SUPERUSER=1

EXPOSE 80

Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/ChatWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ChatWidget extends Component
/** @var array<int, Conversation> */
public array $conversations = [];

/** @var array<int, array{role: string, content: string, citations?: array|null, failed?: bool, error?: array|null}> */
/** @var array<int, array{role: string, content: string, citations?: array|null, failed?: bool, error?: array|null, rating?: string|null, result_ids?: array<int, mixed>|null}> */
public array $messages = [];

public string $draft = '';
Expand Down
1 change: 1 addition & 0 deletions app/Services/AiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function feedback(string $query, string $rating, ?string $answer = null,
return true;
} catch (\Throwable $e) {
$this->logFailure('/feedback', 'best_effort');

return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@

'key' => env('APP_KEY'),

// Dedicated secret for QR code HMAC
'qr_hmac_secret' => env('QR_HMAC_SECRET'),
// Dedicated secret for QR code HMAC (falls back to APP_KEY if not explicitly set)
'qr_hmac_secret' => env('QR_HMAC_SECRET') ?: env('APP_KEY'),

'previous_keys' => [
...array_filter(
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
APP_DEBUG: "true"
APP_URL: ${APP_URL:-http://localhost}
APP_KEY: ${APP_KEY:-}
QR_HMAC_SECRET: ${QR_HMAC_SECRET:-}
DB_CONNECTION: pgsql
DB_HOST: db
DB_PORT: "5432"
Expand Down
14 changes: 5 additions & 9 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@
@import '@fontsource/outfit/900.css';
@import 'tailwindcss';

@plugin "daisyui";

@plugin "daisyui" {
themes:
light --default,
dark --prefersdark;
}

@source "../../vendor/robsontenorio/mary/src/View/Components/**/*.php";

@source "../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php";
@source "../../storage/framework/views/*.php";
@source "../**/*.blade.php";
@source "../**/*.js";
@source "../**/*.vue";
@source "../../vendor/robsontenorio/mary";
@source "../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views";
@source "../../storage/framework/views";
@source "../views";
@source "../js";

/* Dark theme variant support */
@custom-variant dark (&:where(.dark, .dark *));
Expand Down
Loading