Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22e12977f8 | |||
| 732cf02317 | |||
| 6dea75651b | |||
| 6cff252813 | |||
| 0d06ca6a04 | |||
| a3f875270b |
+14
-1
@@ -7,6 +7,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Holding extends Model
|
||||
@@ -253,7 +254,19 @@ class Holding extends Model
|
||||
$date_interval = "date(date, '+1 day')";
|
||||
} else {
|
||||
|
||||
DB::statement('SET cte_max_recursion_depth=1000000;');
|
||||
// MySQL default
|
||||
$max_recursion_var_name = 'cte_max_recursion_depth';
|
||||
|
||||
// Determine if running MySQL or MariaDB
|
||||
$versionString = Arr::get(
|
||||
DB::select('SELECT VERSION() as version;'),
|
||||
'0', new \stdClass
|
||||
)->version;
|
||||
if (stripos($versionString, 'MariaDB') !== false) {
|
||||
$max_recursion_var_name = 'max_recursive_iterations'; // Must be MariaDB
|
||||
}
|
||||
|
||||
DB::statement("SET $max_recursion_var_name=1000000;");
|
||||
}
|
||||
|
||||
return DB::table(DB::raw("(
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ return [
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
'key' => env('APP_KEY') ?: when(file_exists('storage/app/.key'), fn () => trim(file_get_contents('storage/app/.key'))),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
|
||||
+4
-2
@@ -36,10 +36,12 @@ services:
|
||||
container_name: investbrain-redis
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
networks:
|
||||
- investbrain-network
|
||||
command:
|
||||
- --loglevel warning
|
||||
volumes:
|
||||
- investbrain-redis:/data
|
||||
networks:
|
||||
- investbrain-network
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: investbrain-mysql
|
||||
|
||||
+45
-17
@@ -1,17 +1,16 @@
|
||||
FROM php:8.3-fpm
|
||||
# Stage 1: Build stage
|
||||
FROM php:8.3-fpm AS builder
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV APP_NAME=Investbrain
|
||||
ENV VITE_APP_NAME=Investbrain
|
||||
|
||||
# Set the working directory
|
||||
COPY . /var/app
|
||||
WORKDIR /var/app
|
||||
|
||||
# Install required packages
|
||||
RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y \
|
||||
nginx \
|
||||
libfreetype-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
@@ -20,22 +19,18 @@ RUN apt-get update && apt-get upgrade -y \
|
||||
libicu-dev \
|
||||
libpq-dev \
|
||||
binutils libc6-dev \
|
||||
supervisor \
|
||||
unzip curl git \
|
||||
nodejs npm \
|
||||
# Clean up APT
|
||||
&& apt-get -y autoremove \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
||||
# Install PHP extensions
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
gd pgsql zip pdo_mysql mysqli intl
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Remove default nginx config
|
||||
RUN rm /etc/nginx/sites-enabled/default \
|
||||
&& rm -rf /var/www/html \
|
||||
&& ln -s /var/app /var/www/app
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) gd zip
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Install Composer and Node.js Install PHP dependencies and build front end assets
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||
@@ -43,8 +38,41 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
|
||||
&& npm install && npm run build \
|
||||
&& rm -rf node_modules
|
||||
|
||||
# Stage 2: Production stage
|
||||
FROM php:8.3-fpm-alpine
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /var/app
|
||||
|
||||
# Copy necessary files from the builder stage
|
||||
COPY --from=builder /var/app /var/app
|
||||
COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
|
||||
COPY --from=builder /usr/local/bin/composer /usr/local/bin/composer
|
||||
|
||||
# Install required Alpine packages
|
||||
RUN apk add --no-cache \
|
||||
nginx \
|
||||
supervisor \
|
||||
libpng-dev \
|
||||
libzip-dev \
|
||||
icu-dev \
|
||||
postgresql-dev \
|
||||
freetype-dev \
|
||||
libjpeg-turbo-dev \
|
||||
bash \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
gd pgsql zip pdo_mysql mysqli intl
|
||||
|
||||
# Remove default nginx config
|
||||
RUN rm -rf /var/www/html \
|
||||
&& ln -s /var/app /var/www/app
|
||||
|
||||
# Create required directories for supervisord
|
||||
RUN mkdir -p /var/log/supervisor /var/run/supervisor
|
||||
|
||||
# Copy over configs
|
||||
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
# Set permissions and link storage
|
||||
@@ -59,4 +87,4 @@ EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost/up || exit 1
|
||||
|
||||
# Run everything else
|
||||
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]
|
||||
ENTRYPOINT ["/bin/sh", "./docker/entrypoint.sh"]
|
||||
|
||||
+14
-5
@@ -8,7 +8,11 @@ echo "CiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi
|
||||
echo -e "\n====================== Validating environment... ====================== "
|
||||
|
||||
# Ensure app storage directory is scaffolded
|
||||
mkdir -p storage/{{framework/cache,framework/sessions,framework/views},app,logs}
|
||||
mkdir -p storage/framework/cache \
|
||||
storage/framework/sessions \
|
||||
storage/framework/views \
|
||||
storage/app \
|
||||
storage/logs
|
||||
|
||||
# Ensure storage directory is permissioned for www-data
|
||||
chmod -R 775 storage
|
||||
@@ -16,9 +20,9 @@ chown -R www-data:www-data storage
|
||||
|
||||
echo -e "\n > Storage directory scaffolding is OK... "
|
||||
|
||||
# Ensure app key is generated
|
||||
if [[ -z "$APP_KEY" ]]; then
|
||||
echo -e "\n > Oops! The required APP_KEY configuration is missing in your environment! "
|
||||
# Ensure app key exists / generate if required
|
||||
KEY_FILE="storage/app/.key"
|
||||
if [ -z "$APP_KEY" ] && [ ! -s "$KEY_FILE" ]; then
|
||||
|
||||
draw_box() {
|
||||
local text="$1"
|
||||
@@ -30,7 +34,12 @@ if [[ -z "$APP_KEY" ]]; then
|
||||
echo "$border"
|
||||
}
|
||||
|
||||
export APP_KEY=$(php artisan key:generate --show)
|
||||
export APP_KEY="$(php artisan key:generate --show)"
|
||||
|
||||
echo -e "\n > Oops! The required APP_KEY configuration is missing! Generated app key and saved in $KEY_FILE ."
|
||||
|
||||
echo "$APP_KEY" > "$KEY_FILE"
|
||||
|
||||
draw_box $APP_KEY
|
||||
else
|
||||
echo -e "\n > APP_KEY is OK... "
|
||||
|
||||
Reference in New Issue
Block a user