Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: investbrainapp/investbrain
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.3
Choose a base ref
...
head repository: investbrainapp/investbrain
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 8 commits
  • 10 files changed
  • 1 contributor

Commits on Jan 30, 2025

  1. Copy the full SHA
    37da688 View commit details
  2. Copy the full SHA
    a705b79 View commit details

Commits on Jan 31, 2025

  1. fix: make redis default

    hackeresq committed Jan 31, 2025
    Copy the full SHA
    894da4e View commit details
  2. Copy the full SHA
    cac2460 View commit details
  3. Copy the full SHA
    a39f255 View commit details
  4. Copy the full SHA
    1195fac View commit details
  5. Copy the full SHA
    00a1312 View commit details

Commits on Feb 1, 2025

  1. fix: quiet redis logs

    hackeresq authored Feb 1, 2025
    Copy the full SHA
    a3f8752 View commit details
Showing with 75 additions and 51 deletions.
  1. +1 −1 .dockerignore
  2. +0 −1 .env.example
  3. +8 −0 README.md
  4. +1 −1 config/cache.php
  5. +1 −1 config/queue.php
  6. +1 −1 config/session.php
  7. +12 −8 docker-compose.yml
  8. +8 −11 docker/Dockerfile
  9. +33 −22 docker/entrypoint.sh
  10. +10 −5 docker/supervisord.conf
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -13,4 +13,4 @@ storage/framework/cache/*
storage/framework/sessions/*
storage/framework/testing/*
storage/framework/views/*
storage/framework/logs/*
storage/logs/*
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -66,7 +66,6 @@ QUEUE_CONNECTION=redis

CACHE_STORE=redis

REDIS_CLIENT=predis
REDIS_HOST=investbrain-redis
REDIS_PATH=/tmp/database_server.sock
REDIS_PASSWORD=null
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -214,6 +214,14 @@ docker exec -it investbrain-app tail -f storage/logs/laravel.log

<details>

**<summary>Application styling is broken and images are too big</summary>**

If you're serving Investbrain from a DNS name (e.g. example.com), it's likely that you haven't updated the `ASSET_URL` environment yet. The URL provided there will be used to generate absolute URLs for images, JS, and CSS assets on the front end of the application.

</details>

<details>

**<summary>Market data not refreshing on fresh install</summary>**

If you're unable to refresh market data out of the box (i.e. your market data provider is set to Yahoo), there is a chance Yahoo is being blocked by a firewall or adblocker. Pihole is known to block `fc.yahoo.com` which is the domain used to query Yahoo.
2 changes: 1 addition & 1 deletion config/cache.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
|
*/

'default' => env('CACHE_STORE', 'database'),
'default' => env('CACHE_STORE', 'redis'),

/*
|--------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion config/queue.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
|
*/

'default' => env('QUEUE_CONNECTION', 'database'),
'default' => env('QUEUE_CONNECTION', 'redis'),

/*
|--------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
|
*/

'driver' => env('SESSION_DRIVER', 'database'),
'driver' => env('SESSION_DRIVER', 'redis'),

/*
|--------------------------------------------------------------------------
20 changes: 12 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -8,23 +8,24 @@ services:
restart: unless-stopped
tty: true
ports:
- "${APP_PORT:-8000}:80"
environment:
- 8000:80
environment: # You can either use these properties OR an .env file. Do not use both!
APP_KEY: "" # Generate a key using `echo base64:$(openssl rand -base64 32)`
APP_URL: "http://localhost:8000"
ASSET_URL: "http://localhost:8000"
DB_CONNECTION: mysql
DB_HOST: investbrain-mysql
DB_PORT: 3306
DB_DATABASE: ${DB_DATABASE:-investbrain}
DB_USERNAME: ${DB_USERNAME:-investbrain}
DB_PASSWORD: ${DB_PASSWORD:-investbrain}
DB_DATABASE: investbrain
DB_USERNAME: investbrain
DB_PASSWORD: investbrain
SESSION_DRIVER: redis
QUEUE_CONNECTION: redis
CACHE_STORE: redis
REDIS_HOST: investbrain-redis
volumes:
- ./storage:/var/app/storage
- investbrain-storage:/var/app/storage # You can use a volume...
# - /path/to/storage:/var/app/storage # ...or you can use a path on host
depends_on:
- mysql
- redis
@@ -35,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
@@ -55,5 +58,6 @@ services:
networks:
- investbrain-network
volumes:
investbrain-storage:
investbrain-redis:
investbrain-mysql:
19 changes: 8 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ FROM php:8.3-fpm
ENV DEBIAN_FRONTEND=noninteractive
ENV APP_NAME=Investbrain
ENV VITE_APP_NAME=Investbrain
ENV APP_DEBUG=true
ENV SELF_HOSTED=true

# Set the working directory
COPY . /var/app
@@ -39,27 +37,26 @@ RUN rm /etc/nginx/sites-enabled/default \
&& rm -rf /var/www/html \
&& ln -s /var/app /var/www/app

# Set permissions and ensure www-data has a shell available
RUN chown -R www-data:www-data . \
&& chmod -R 775 ./storage \
&& chmod +x ./docker/entrypoint.sh \
&& usermod -s /bin/bash www-data

# 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 \
&& composer install --no-scripts --optimize-autoloader \
&& npm install && npm run build
&& npm install && npm run build \
&& rm -rf node_modules

# Copy over configs
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Set permissions and link storage
RUN php artisan storage:link \
&& chown -R www-data:www-data . \
&& chmod +x ./docker/entrypoint.sh

# Serve on port 80
EXPOSE 80

# Set up healthcheck
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost || exit 1
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost/up || exit 1

# Run everything else
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]

55 changes: 33 additions & 22 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -2,25 +2,23 @@

cd /var/app

# Starting Investbrain
echo "CiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICAqICBJSUkgICBOICAgTiAgViAgIFYgIEVFRUVFICBTU1NTICBUVFRUVCAgQkJCQkIgICBSUlJSICAgIEFBQUFBICBJSUkgICBOICAgTiAgKgogICogICBJICAgIE5OICBOICBWICAgViAgRSAgICAgIFMgICAgICAgVCAgICBCICAgIEIgIFIgICBSICAgQSAgIEEgICBJICAgIE5OICBOICAqCiAgKiAgIEkgICAgTiBOIE4gIFYgICBWICBFRUVFICAgU1NTUyAgICBUICAgIEJCQkJCICAgUlJSUiAgICBBQUFBQSAgIEkgICAgTiBOIE4gICoKICAqICAgSSAgICBOICBOTiAgViAgIFYgIEUgICAgICAgICAgUyAgIFQgICAgQiAgICBCICBSICBSICAgIEEgICBBICAgSSAgICBOICBOTiAgKgogICogIElJSSAgIE4gICBOICAgVlZWICAgRUVFRUUgIFNTU1MgICAgVCAgICBCQkJCQiAgIFIgICBSICAgQSAgIEEgIElJSSAgIE4gICBOICAqCiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICA=" | base64 -d

echo -e "\n====================== Validating environment... ====================== "
for dir in storage/framework/cache storage/framework/sessions storage/framework/views; do
if [ ! -d "$dir" ]; then
echo -e "\n > $dir is missing. Creating scaffold for storage directory... "
mkdir -p storage/framework/{cache,sessions,views}
chmod -R 775 storage
chown -R www-data:www-data storage
fi
done

if [ ! -L "public/storage" ]; then
echo -e "\n > Creating symbolic link for app public storage... "

php artisan storage:link
fi
# Ensure app storage directory is scaffolded
mkdir -p storage/{{framework/cache,framework/sessions,framework/views},app,logs}

# Ensure storage directory is permissioned for www-data
chmod -R 775 storage
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! "
echo -e "\n > You should set this APP_KEY in your .env file! "

draw_box() {
local text="$1"
@@ -34,23 +32,36 @@ if [[ -z "$APP_KEY" ]]; then

export APP_KEY=$(php artisan key:generate --show)
draw_box $APP_KEY
else
echo -e "\n > APP_KEY is OK... "
fi

echo -e "\n====================== Running migrations... ====================== "

# Wait 60 seconds for database to be ready
RETRIES=12
DELAY=5
run_migrations() {
php artisan migrate --force
sleep $DELAY
# php artisan migrate --force
output=$(php artisan migrate --force 2>/dev/null)
if [[ $? -eq 0 ]]; then
echo "$output"
return 0
else
return 1
fi
}
RETRIES=12 # wait 60 seconds for database to be ready
DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
echo -e "\n > Database is not ready after $RETRIES attempts. Exiting... "
if [[ $RETRIES -le 0 ]]; then
echo -e "\n > Database is not ready after one minute. Exiting... \n"
exit 1
fi
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. "
sleep $DELAY
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. \n"
done

echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n"
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf

exec supervisord -c /etc/supervisor/conf.d/supervisord.conf

15 changes: 10 additions & 5 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -2,33 +2,38 @@
nodaemon=true
user=root
pidfile=/var/run/supervisord.pid
logfile=/var/log/supervisor/supervisord.log

[program:nginx]
command=nginx -g 'daemon off;'
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true

[program:php]
command=php-fpm -F
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true

[program:scheduler]
command=php artisan schedule:work
user=www-data
autorestart=true
redirect_stderr=true
redirect_stdout=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0

[program:queue-worker]
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
user=www-data
autorestart=true
redirect_stderr=true
redirect_stdout=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
numprocs=2
stopasgroup=true
killasgroup=true

[supervisorctl]