Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cad9b83fb | |||
| 780ee76dc3 | |||
| 4d8e17f59f | |||
| 21c27e22da | |||
| 2e978089b5 | |||
| 803fe7147e | |||
| 6490364a5d | |||
| 2ad773952e | |||
| 138e71107e | |||
| bde399f589 | |||
| 8a43602363 | |||
| 5a56790fd4 | |||
| 892f681174 | |||
| 997b5420ee | |||
| 643bbe3af2 | |||
| f85f0f19b9 | |||
| 3f9a1bafa0 | |||
| 6f72a03ecf | |||
| 5b8e4c634e |
@@ -0,0 +1,10 @@
|
||||
.git
|
||||
.env
|
||||
node_modules
|
||||
packages
|
||||
vendor
|
||||
tests
|
||||
.DS_Store
|
||||
vapor.yml
|
||||
.vapor
|
||||
storage
|
||||
+1
-1
@@ -52,7 +52,7 @@ QUEUE_CONNECTION=redis
|
||||
CACHE_STORE=redis
|
||||
|
||||
REDIS_CLIENT=predis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_HOST=investbrain-redis
|
||||
REDIS_PATH=/tmp/database_server.sock
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Build and push Docker images
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GIT_HUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Extract version from tag
|
||||
id: extract-version
|
||||
run: |
|
||||
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: ./docker/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
investbrainapp/investbrain:latest
|
||||
investbrainapp/investbrain:${{ env.version }}
|
||||
ghcr.io/investbrainapp/investbrain:latest
|
||||
ghcr.io/investbrainapp/investbrain:${{ env.version }}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Investbrain is a smart open-source investment tracker that helps you manage, tra
|
||||
|
||||
## Under the hood
|
||||
|
||||
Investbrain is a Laravel PHP web application that leverages Livewire and Tailwind for its frontend. Most databases should work, including MySQL and SQLite. Out of the box, we feature three market data providers: [Yahoo Finance](https://finance.yahoo.com/), [Finnhub](https://finnhub.io/pricing-stock-api-market-data), and [Alpha Vantage](https://www.alphavantage.co/support/). But we also offer an extensible market data provider interface for intrepid developers to create their own! We also offer an integration with OpenAI for our ["chat with your holdings"](#chat-with-your-holdings) capability. Finally, of course we have robust support for i18n, a11y, and dark mode.
|
||||
Investbrain is a Laravel PHP web application that leverages Livewire and Tailwind for its frontend. Most databases should work, including MySQL and SQLite. Out of the box, we feature three market data providers: [Yahoo Finance](https://finance.yahoo.com/), [Finnhub](https://finnhub.io/pricing-stock-api-market-data), and [Alpha Vantage](https://www.alphavantage.co/support/). But we also offer an extensible market data provider interface for intrepid developers to create their own! We also offer integrations with OpenAI and Ollama for our ["chat with your holdings"](#chat-with-your-holdings) capability. Finally, of course we have robust support for i18n, a11y, and dark mode.
|
||||
|
||||
## Self hosting
|
||||
|
||||
@@ -109,11 +109,11 @@ Feel free to submit a PR with any custom providers you create.
|
||||
|
||||
## Import / Export
|
||||
|
||||
Investbrain includes a convenient feature which allows you to import and export portfolios and transaction data.
|
||||
Investbrain includes a convenient feature which allows you to maintain the portability of your portfolios and transaction data.
|
||||
|
||||
### Import
|
||||
|
||||
Imports are "upserted" to the database. If the record does not already exist in the database, the record will be created. However, when a portfolio or transaction exists (the record's ID matches an existing record), the record will be updated. This way, you can simultaneously create new records, but also bulk update records.
|
||||
Imports are "upserted" to the database. If the record does not already exist in the database, the record will be created. However, when a portfolio or transaction exists (i.e. the record's ID matches an existing record), the record will be updated. This way, you can simultaneously create new records, but also bulk update records.
|
||||
|
||||
### Export
|
||||
|
||||
|
||||
+12
-3
@@ -3,9 +3,7 @@ networks:
|
||||
driver: bridge
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
image: investbrainapp/investbrain:latest
|
||||
container_name: investbrain-app
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
@@ -15,8 +13,18 @@ services:
|
||||
- .:/var/www/app:delegated
|
||||
depends_on:
|
||||
- mysql
|
||||
- redis
|
||||
networks:
|
||||
- investbrain-network
|
||||
redis:
|
||||
image: redis:alpine
|
||||
container_name: investbrain-redis
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
networks:
|
||||
- investbrain-network
|
||||
volumes:
|
||||
- investbrain-redis:/data
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: investbrain-nginx
|
||||
@@ -46,4 +54,5 @@ services:
|
||||
networks:
|
||||
- investbrain-network
|
||||
volumes:
|
||||
investbrain-redis:
|
||||
investbrain-mysql:
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
dump.rdb
|
||||
+34
-30
@@ -1,47 +1,51 @@
|
||||
FROM php:8.3-fpm
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Set the working directory
|
||||
COPY . /var/www/app
|
||||
WORKDIR /var/www/app
|
||||
|
||||
# Set permissions
|
||||
RUN chown -R www-data:www-data . \
|
||||
&& chmod -R 775 ./storage \
|
||||
&& chmod +x ./docker/entrypoint.sh \
|
||||
# Install common php extension dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
zlib1g-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
libicu-dev \
|
||||
git \
|
||||
curl \
|
||||
redis \
|
||||
supervisor \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
gd \
|
||||
zip \
|
||||
pdo_mysql \
|
||||
mysqli \
|
||||
intl
|
||||
|
||||
&& apt-get update && apt-get install -y \
|
||||
libfreetype-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
zlib1g-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
libicu-dev \
|
||||
git \
|
||||
curl \
|
||||
supervisor \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
gd \
|
||||
zip \
|
||||
pdo_mysql \
|
||||
mysqli \
|
||||
intl \
|
||||
# Install Node.js and npm
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& npm install -g npm@latest
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& npm install -g npm@latest
|
||||
|
||||
# Copy over supervisor configuration
|
||||
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
# Update permissions
|
||||
RUN chown -R www-data:www-data . \
|
||||
&& chmod -R 775 ./storage \
|
||||
&& chmod +x ./docker/entrypoint.sh
|
||||
|
||||
# install composer
|
||||
# Install composer
|
||||
COPY --from=composer:2.6.5 /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
# Serve on port 80
|
||||
EXPOSE 80
|
||||
|
||||
# Set up healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost || exit 1
|
||||
|
||||
# Run everything else
|
||||
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]
|
||||
CMD ["./docker/entrypoint.sh"]
|
||||
|
||||
Executable → Regular
+20
-10
@@ -2,20 +2,17 @@
|
||||
|
||||
cd /var/www/app
|
||||
|
||||
echo "====================== Running entrypoint script... ====================== "
|
||||
echo -e "\n====================== Running entrypoint script... ====================== "
|
||||
if [ ! -f ".env" ]; then
|
||||
echo " > Ope, gotta create an .env file!"
|
||||
|
||||
cp .env.example .env
|
||||
fi
|
||||
|
||||
echo "====================== Checking for updates... ====================== "
|
||||
/usr/bin/git pull
|
||||
|
||||
echo "====================== Installing Composer dependencies... ====================== "
|
||||
echo -e "\n====================== Installing Composer dependencies... ====================== "
|
||||
/usr/local/bin/composer install
|
||||
|
||||
echo "====================== Validating environment... ====================== "
|
||||
echo -e "\n====================== Validating environment... ====================== "
|
||||
if [ $(stat -c '%U' .) != "www-data" ]; then
|
||||
echo " > Setting correct permissions for pwd..."
|
||||
chown -R www-data:www-data .
|
||||
@@ -33,12 +30,25 @@ if [ ! -L "public/storage" ]; then
|
||||
/usr/local/bin/php artisan storage:link
|
||||
fi
|
||||
|
||||
echo "====================== Installing NPM dependencies and building frontend... ====================== "
|
||||
echo -e "\n====================== Installing NPM dependencies and building frontend... ====================== "
|
||||
/usr/bin/npm install
|
||||
/usr/bin/npm run build
|
||||
|
||||
echo "====================== Running migrations... ====================== "
|
||||
/usr/local/bin/php artisan migrate --force
|
||||
echo -e "\n====================== Running migrations... ====================== "
|
||||
run_migrations() {
|
||||
/usr/local/bin/php artisan migrate --force
|
||||
}
|
||||
RETRIES=30
|
||||
DELAY=5
|
||||
until run_migrations; do
|
||||
RETRIES=$((RETRIES-1))
|
||||
if [ $RETRIES -le 0 ]; then
|
||||
echo " > Database is not ready after multiple attempts. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
echo " > Waiting for database to be ready... retrying in $DELAY seconds."
|
||||
sleep $DELAY
|
||||
done
|
||||
|
||||
echo "====================== Spinning up Supervisor daemon... ====================== "
|
||||
echo -e "\n====================== Spinning up Supervisor daemon... ====================== "
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Redis RDB and AOF file location
|
||||
dir /var/www/app/docker
|
||||
@@ -11,13 +11,6 @@ autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/php.log
|
||||
stderr_logfile=/var/log/supervisor/php_error.log
|
||||
|
||||
[program:redis]
|
||||
command=redis-server /var/www/app/docker/redis.conf
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/redis.log
|
||||
stderr_logfile=/var/log/supervisor/redis_error.log
|
||||
|
||||
[program:scheduler]
|
||||
command=php artisan schedule:work
|
||||
autorestart=true
|
||||
|
||||
Generated
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "investbrain",
|
||||
"name": "app",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -5,7 +5,7 @@ use App\Models\AiChat;
|
||||
use App\Models\Holding;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Livewire\Volt\Component;
|
||||
use OpenAI;
|
||||
use OpenAI\Factory;
|
||||
use OpenAI\Responses\StreamResponse;
|
||||
|
||||
new class extends Component {
|
||||
@@ -202,10 +202,6 @@ new class extends Component {
|
||||
$organization = config('openai.organization');
|
||||
$baseUri = config('openai.base_uri');
|
||||
|
||||
if (! is_string($apiKey) || ($organization !== null && ! is_string($organization))) {
|
||||
throw new \InvalidArgumentException('The OpenAI API Key is missing. Please publish the [openai.php] configuration file and set the [api_key].');
|
||||
}
|
||||
|
||||
return OpenAI::factory()
|
||||
->withApiKey($apiKey)
|
||||
->withOrganization($organization)
|
||||
|
||||
Reference in New Issue
Block a user