Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e3c993a15 | |||
| 4220bb629f | |||
| bdd30c238c | |||
| 778d799113 | |||
| 47cd1b6a91 | |||
| 118232e906 | |||
| 64c84fe708 | |||
| cff3c02851 | |||
| 60577d02c7 | |||
| 99749bd9c9 | |||
| b3ca2e5927 | |||
| b71e9e2e80 | |||
| 72a8aacabe | |||
| a0e9cfb40d | |||
| 46707c1149 | |||
| 497efcfa76 | |||
| 1201c248ee | |||
| 395eb31801 | |||
| b27edd9818 | |||
| 51c43e9893 | |||
| ec2019430e | |||
| 05174e93ad | |||
| e8ec94bfa8 | |||
| c6642e028c | |||
| 6d5a5f46b9 | |||
| e651eb86ca | |||
| 84171da29b | |||
| d463ec689b | |||
| 416a82058b | |||
| 6f2324ad1b | |||
| c19f13edc1 | |||
| 390b137e0b | |||
| 0c7d4a83f1 | |||
| 25112cb03a | |||
| 5ade4b35a0 | |||
| 00067c56d4 | |||
| 620566490b | |||
| 7245f4cc69 | |||
| 575fecb163 | |||
| 4120b1abfa | |||
| 801d3739fc | |||
| 92bdf14508 | |||
| fa25a82693 | |||
| 1684f3e0cb | |||
| a31f807da8 | |||
| 6d92b49f3d | |||
| 11cdf975bc | |||
| 7bacc28e3b | |||
| 4bbb71d434 | |||
| 8da153a476 | |||
| 1189325638 | |||
| e93459ae55 | |||
| b1fcf51546 | |||
| 75716368bb | |||
| ec15e2bb63 | |||
| 9a3e030ce7 | |||
| 4f5894ef4a | |||
| e0b5610d90 | |||
| bc34519a26 | |||
| dc69bfa8c7 | |||
| cf7c5fc23a | |||
| 16d5b80657 | |||
| 8dd153fb53 | |||
| 89bfb28019 | |||
| 1215e47297 | |||
| 4016899179 | |||
| 1cad9b83fb | |||
| 780ee76dc3 | |||
| 4d8e17f59f | |||
| 21c27e22da | |||
| 2e978089b5 | |||
| 803fe7147e | |||
| 6490364a5d | |||
| 2ad773952e | |||
| 138e71107e | |||
| bde399f589 | |||
| 8a43602363 | |||
| 5a56790fd4 | |||
| 892f681174 | |||
| 997b5420ee | |||
| 643bbe3af2 | |||
| f85f0f19b9 |
@@ -0,0 +1,16 @@
|
|||||||
|
.git
|
||||||
|
.env
|
||||||
|
node_modules
|
||||||
|
packages
|
||||||
|
vendor
|
||||||
|
tests
|
||||||
|
.DS_Store
|
||||||
|
vapor.yml
|
||||||
|
.vapor
|
||||||
|
storage/app/livewire-tmp/*
|
||||||
|
storage/app/public/profile-photos/*
|
||||||
|
storage/framework/cache/*
|
||||||
|
storage/framework/sessions/*
|
||||||
|
storage/framework/testing/*
|
||||||
|
storage/framework/views/*
|
||||||
|
storage/framework/logs/*
|
||||||
+25
-10
@@ -1,24 +1,35 @@
|
|||||||
APP_NAME=Investbrain
|
# Generate a secure key using `openssl rand -base64 32`
|
||||||
APP_ENV=production
|
|
||||||
APP_KEY=
|
APP_KEY=
|
||||||
APP_DEBUG=true
|
|
||||||
APP_TIMEZONE=UTC
|
# Port for NGINX to listen on
|
||||||
APP_PORT=8000
|
APP_PORT=8000
|
||||||
|
|
||||||
|
# Used internally to generate absolute links
|
||||||
APP_URL="http://localhost:${APP_PORT}"
|
APP_URL="http://localhost:${APP_PORT}"
|
||||||
SELF_HOSTED=true
|
|
||||||
|
# Webroot for static assets (css, js, images, etc)
|
||||||
|
ASSET_URL="${APP_URL}"
|
||||||
|
|
||||||
|
# Enables or disables new user registration
|
||||||
REGISTRATION_ENABLED=true
|
REGISTRATION_ENABLED=true
|
||||||
|
|
||||||
# ASSET_URL="http://localhost:8000" # (optional) webroot for static assets (css, js, images, etc)
|
# Enable or disable AI chat feature
|
||||||
|
|
||||||
AI_CHAT_ENABLED=false
|
AI_CHAT_ENABLED=false
|
||||||
|
|
||||||
|
# API key for OpenAI (for Llama support, see docs)
|
||||||
OPENAI_API_KEY=
|
OPENAI_API_KEY=
|
||||||
OPENAI_ORGANIZATION=
|
OPENAI_ORGANIZATION=
|
||||||
|
|
||||||
|
# Market data provider to use (comma separated list)
|
||||||
MARKET_DATA_PROVIDER=yahoo
|
MARKET_DATA_PROVIDER=yahoo
|
||||||
MARKET_DATA_REFRESH=30
|
|
||||||
ALPHAVANTAGE_API_KEY=
|
ALPHAVANTAGE_API_KEY=
|
||||||
FINNHUB_API_KEY=
|
FINNHUB_API_KEY=
|
||||||
|
|
||||||
|
# Cadence to refresh market data (in minutes)
|
||||||
|
MARKET_DATA_REFRESH=30
|
||||||
|
DAILY_CHANGE_TIME=
|
||||||
|
|
||||||
|
#### Advanced configurations ####
|
||||||
ENABLED_LOGIN_PROVIDERS=
|
ENABLED_LOGIN_PROVIDERS=
|
||||||
GITHUB_CLIENT_ID=
|
GITHUB_CLIENT_ID=
|
||||||
GITHUB_CLIENT_SECRET=
|
GITHUB_CLIENT_SECRET=
|
||||||
@@ -29,9 +40,13 @@ LINKEDIN_CLIENT_SECRET=
|
|||||||
FACEBOOK_CLIENT_ID=
|
FACEBOOK_CLIENT_ID=
|
||||||
FACEBOOK_CLIENT_SECRET=
|
FACEBOOK_CLIENT_SECRET=
|
||||||
|
|
||||||
|
APP_NAME=Investbrain
|
||||||
|
APP_TIMEZONE=UTC
|
||||||
|
APP_ENV=production
|
||||||
|
APP_DEBUG=true
|
||||||
APP_LOCALE=en
|
APP_LOCALE=en
|
||||||
APP_FALLBACK_LOCALE=en
|
APP_FALLBACK_LOCALE=en
|
||||||
APP_FAKER_LOCALE=en_US
|
SELF_HOSTED=true
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=investbrain-mysql
|
DB_HOST=investbrain-mysql
|
||||||
@@ -52,7 +67,7 @@ QUEUE_CONNECTION=redis
|
|||||||
CACHE_STORE=redis
|
CACHE_STORE=redis
|
||||||
|
|
||||||
REDIS_CLIENT=predis
|
REDIS_CLIENT=predis
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=investbrain-redis
|
||||||
REDIS_PATH=/tmp/database_server.sock
|
REDIS_PATH=/tmp/database_server.sock
|
||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
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 }}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<p align="center"><a href="https://investbra.in" target="_blank"><img src="https://raw.githubusercontent.com/investbrainapp/investbrain/main/investbrain-logo.png" width="400" alt="Investbrain Logo"></a></p>
|
<p align="center"><a href="https://investbra.in" target="_blank"><img src="https://raw.githubusercontent.com/investbrainapp/investbrain/main/investbrain-logo.png" width="400" alt="Investbrain Logo"></a></p>
|
||||||
|
|
||||||
|
[](https://github.com/investbrainapp/investbrain/)
|
||||||
|
[](https://github.com/investbrainapp/investbrain/)
|
||||||
|
[](https://github.com/investbrainapp/investbrain/issues)
|
||||||
|
[](https://hub.docker.com/r/investbrainapp/investbrain/)
|
||||||
|
|
||||||
|
|
||||||
## About Investbrain
|
## About Investbrain
|
||||||
|
|
||||||
Investbrain is a smart open-source investment tracker that helps you manage, track, and make informed decisions about your investments.
|
Investbrain is a smart open-source investment tracker that helps you manage, track, and make informed decisions about your investments.
|
||||||
@@ -20,31 +28,31 @@ Investbrain is a smart open-source investment tracker that helps you manage, tra
|
|||||||
|
|
||||||
## Under the hood
|
## 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
|
## Self hosting
|
||||||
|
|
||||||
For ease of installation, we _highly recommend_ installing Investbrain using the provided [Docker Compose](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file, which downloads all the necessary dependencies and seamlessly builds everything you need to get started quickly!
|
For ease of installation, we _highly recommend_ installing Investbrain using the provided [Docker Compose](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file, which uses the official Investbrain Docker image and includes all the necessary dependencies to seamlessly build everything you need to get started quickly!
|
||||||
|
|
||||||
Before getting started, you should already have the following installed on your machine: [Docker Engine](https://docs.docker.com/engine/install/), [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), and a wild sense of adventure.
|
Before getting started, you should already have [Docker Engine](https://docs.docker.com/engine/install/) installed on your machine.
|
||||||
|
|
||||||
Ready? Let's get started!
|
Ready? Let's get started!
|
||||||
|
|
||||||
First, you can clone this repository:
|
**1. Copy Docker Compose file**
|
||||||
|
|
||||||
```bash
|
Grab a copy of the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml)** file and paste the contents into the directory where you plan to install Investbrain.
|
||||||
git clone https://github.com/investbrainapp/investbrain.git && cd investbrain
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, build the Docker image and bring up the container (this will take a few minutes):
|
**2. Set your environment**
|
||||||
|
|
||||||
```bash
|
Adjust the `environment` properties in the Docker Compose file to your preferences.
|
||||||
docker compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
In the previous step, all of the default configurations are set automatically. This includes creating a .env file and setting the required Laravel `APP_KEY`.
|
_Particularly_, you need to set the `APP_KEY` value to a complex random value. If you're unsure, you can run `openssl rand -base64 32` from your terminal to generate a strong application key.
|
||||||
|
|
||||||
If everything worked as expected, you should now be able to access Investbrain in the browser at. You should create an account by visiting:
|
> Tip: Want to know what options are available? You can reference the [.env.example](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file in this respository for available environment configurations.
|
||||||
|
|
||||||
|
**3. Run `docker compose up`**
|
||||||
|
|
||||||
|
This might take a few minutes. But if everything worked as expected, you should now be able to access Investbrain in the browser by visiting:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
http://localhost:8000/register
|
http://localhost:8000/register
|
||||||
@@ -109,11 +117,11 @@ Feel free to submit a PR with any custom providers you create.
|
|||||||
|
|
||||||
## Import / Export
|
## 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
|
### 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
|
### Export
|
||||||
|
|
||||||
@@ -127,6 +135,7 @@ There are several optional configurations available when installing using the re
|
|||||||
| ------------- | ------------- | ------------- |
|
| ------------- | ------------- | ------------- |
|
||||||
| APP_URL | The URL where your Investbrain installation will be accessible | http://localhost |
|
| APP_URL | The URL where your Investbrain installation will be accessible | http://localhost |
|
||||||
| APP_PORT | The HTTP port exposed by the NGINX container | 8000 |
|
| APP_PORT | The HTTP port exposed by the NGINX container | 8000 |
|
||||||
|
| APP_KEY | Must be set during install - encryption key for various security-related functions | `null` |
|
||||||
| MARKET_DATA_PROVIDER | The market data provider to use (either `yahoo`, `alphavantage`, or `finnhub`) | yahoo |
|
| MARKET_DATA_PROVIDER | The market data provider to use (either `yahoo`, `alphavantage`, or `finnhub`) | yahoo |
|
||||||
| ALPHAVANTAGE_API_KEY | If using the Alpha Vantage provider | `null` |
|
| ALPHAVANTAGE_API_KEY | If using the Alpha Vantage provider | `null` |
|
||||||
| FINNHUB_API_KEY | If using the Finnhub provider | `null` |
|
| FINNHUB_API_KEY | If using the Finnhub provider | `null` |
|
||||||
@@ -141,7 +150,7 @@ There are several optional configurations available when installing using the re
|
|||||||
| REGISTRATION_ENABLED | Whether to enable registration of new users | `true` |
|
| REGISTRATION_ENABLED | Whether to enable registration of new users | `true` |
|
||||||
|
|
||||||
|
|
||||||
> Note: These options affect the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file, so if you decide to make any changes to these default configurations, you'll have to restart the Docker containers before your changes take effect.
|
> Note: These options affect the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file and are cached during run-time. If change any .env values, you'll have to restart the containers before your changes take effect.
|
||||||
|
|
||||||
## Updating
|
## Updating
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -5,9 +5,12 @@
|
|||||||
"keywords": ["stocks", "dividends", "investments", "tracking"],
|
"keywords": ["stocks", "dividends", "investments", "tracking"],
|
||||||
"license": "CC-BY-NC 4.0",
|
"license": "CC-BY-NC 4.0",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.3",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
"finnhub/client": "master@dev",
|
"finnhub/client": "master@dev",
|
||||||
"laravel/framework": "^11.9",
|
"laravel/framework": "^11.35",
|
||||||
"laravel/jetstream": "^5.1",
|
"laravel/jetstream": "^5.1",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/socialite": "^5.16",
|
"laravel/socialite": "^5.16",
|
||||||
|
|||||||
Generated
+573
-337
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -13,7 +13,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'name' => env('APP_NAME', 'Laravel'),
|
'name' => env('APP_NAME', 'Investbrain'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -143,7 +143,7 @@ return [
|
|||||||
|
|
||||||
'redis' => [
|
'redis' => [
|
||||||
|
|
||||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
'client' => env('REDIS_CLIENT', 'predis'),
|
||||||
|
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ return [
|
|||||||
|
|
||||||
'from' => [
|
'from' => [
|
||||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
'name' => env('MAIL_FROM_NAME', 'Investbrain'),
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
+30
-20
@@ -3,34 +3,42 @@ networks:
|
|||||||
driver: bridge
|
driver: bridge
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
image: investbrainapp/investbrain:latest
|
||||||
context: .
|
|
||||||
dockerfile: docker/Dockerfile
|
|
||||||
container_name: investbrain-app
|
container_name: investbrain-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
tty: true
|
tty: true
|
||||||
expose:
|
|
||||||
- "9000"
|
|
||||||
volumes:
|
|
||||||
- .:/var/www/app:delegated
|
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
networks:
|
|
||||||
- investbrain-network
|
|
||||||
nginx:
|
|
||||||
image: nginx:alpine
|
|
||||||
container_name: investbrain-nginx
|
|
||||||
restart: unless-stopped
|
|
||||||
tty: true
|
|
||||||
ports:
|
ports:
|
||||||
- "${APP_PORT:-8000}:80"
|
- "${APP_PORT:-8000}:80"
|
||||||
|
environment:
|
||||||
|
- APP_KEY= # Generate a key using `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=investbrain
|
||||||
|
- DB_USERNAME=investbrain
|
||||||
|
- DB_PASSWORD=investbrain
|
||||||
|
- SESSION_DRIVER=redis
|
||||||
|
- QUEUE_CONNECTION=redis
|
||||||
|
- CACHE_STORE=redis
|
||||||
|
- REDIS_HOST=investbrain-redis
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
|
- ./storage:/var/www/app/storage:delegated
|
||||||
- .:/var/www/app:delegated
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- app
|
- mysql
|
||||||
|
- redis
|
||||||
networks:
|
networks:
|
||||||
- investbrain-network
|
- investbrain-network
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
container_name: investbrain-redis
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
networks:
|
||||||
|
- investbrain-network
|
||||||
|
volumes:
|
||||||
|
- investbrain-redis:/data
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:8.0
|
image: mysql:8.0
|
||||||
container_name: investbrain-mysql
|
container_name: investbrain-mysql
|
||||||
@@ -40,10 +48,12 @@ services:
|
|||||||
MYSQL_USER: ${DB_USERNAME:-investbrain}
|
MYSQL_USER: ${DB_USERNAME:-investbrain}
|
||||||
MYSQL_PASSWORD: ${DB_PASSWORD:-investbrain}
|
MYSQL_PASSWORD: ${DB_PASSWORD:-investbrain}
|
||||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-investbrain}
|
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-investbrain}
|
||||||
|
command:
|
||||||
|
- --cte-max-recursion-depth=25000
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/mysql.conf:/etc/mysql/conf.d/my.cnf
|
|
||||||
- investbrain-mysql:/var/lib/mysql
|
- investbrain-mysql:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
- investbrain-network
|
- investbrain-network
|
||||||
volumes:
|
volumes:
|
||||||
|
investbrain-redis:
|
||||||
investbrain-mysql:
|
investbrain-mysql:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
dump.rdb
|
|
||||||
+48
-30
@@ -1,6 +1,10 @@
|
|||||||
FROM php:8.3-fpm
|
FROM php:8.3-fpm
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
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
|
# Set the working directory
|
||||||
COPY . /var/www/app
|
COPY . /var/www/app
|
||||||
@@ -8,40 +12,54 @@ WORKDIR /var/www/app
|
|||||||
|
|
||||||
# Install common php extension dependencies
|
# Install common php extension dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
libfreetype-dev \
|
nginx \
|
||||||
libjpeg62-turbo-dev \
|
libfreetype-dev \
|
||||||
libpng-dev \
|
libjpeg62-turbo-dev \
|
||||||
zlib1g-dev \
|
libpng-dev \
|
||||||
libzip-dev \
|
zlib1g-dev \
|
||||||
unzip \
|
libzip-dev \
|
||||||
libicu-dev \
|
libicu-dev \
|
||||||
git \
|
libpq-dev \
|
||||||
curl \
|
supervisor \
|
||||||
redis \
|
|
||||||
supervisor \
|
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||||
&& docker-php-ext-install -j$(nproc) \
|
&& docker-php-ext-install -j$(nproc) \
|
||||||
gd \
|
gd pgsql zip pdo_mysql mysqli intl \
|
||||||
zip \
|
&& apt-get -y autoremove \
|
||||||
pdo_mysql \
|
&& apt-get clean \
|
||||||
mysqli \
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
intl
|
|
||||||
|
|
||||||
# Install Node.js and npm
|
# Set permissions
|
||||||
RUN 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 . \
|
RUN chown -R www-data:www-data . \
|
||||||
&& chmod -R 775 ./storage \
|
&& chmod -R 775 ./storage \
|
||||||
&& chmod +x ./docker/entrypoint.sh
|
&& chmod +x ./docker/entrypoint.sh \
|
||||||
|
&& usermod -s /bin/bash www-data
|
||||||
|
|
||||||
# install composer
|
# Install Composer and Node.js
|
||||||
COPY --from=composer:2.6.5 /usr/bin/composer /usr/local/bin/composer
|
RUN apt-get update && apt-get install -y \
|
||||||
|
curl \
|
||||||
|
unzip \
|
||||||
|
git \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
# Install PHP dependencies and build front end assets
|
||||||
|
RUN composer install --no-scripts --optimize-autoloader \
|
||||||
|
&& npm install && npm run build
|
||||||
|
|
||||||
|
# Remove default nginx config
|
||||||
|
RUN rm /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
|
# Copy over configs
|
||||||
|
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
|
# 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
|
# Run everything else
|
||||||
CMD ["./docker/entrypoint.sh"]
|
ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"]
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+43
-30
@@ -2,43 +2,56 @@
|
|||||||
|
|
||||||
cd /var/www/app
|
cd /var/www/app
|
||||||
|
|
||||||
echo "====================== Running entrypoint script... ====================== "
|
echo -e "\n====================== Validating environment... ====================== "
|
||||||
if [ ! -f ".env" ]; then
|
if [[ -z "$APP_KEY" ]]; then
|
||||||
echo " > Ope, gotta create an .env file!"
|
echo -e "\n > Oops! The required APP_KEY configuration is missing in your environment! "
|
||||||
|
echo -e "\n > Generating a key (see below) but this will NOT be persisted between container restarts. "
|
||||||
|
echo -e "\n > You should set this APP_KEY in your .env file! "
|
||||||
|
|
||||||
cp .env.example .env
|
draw_box() {
|
||||||
|
local text="$1"
|
||||||
|
local length=${#text}
|
||||||
|
local border=$(printf '%*s' "$((length + 4))" | tr ' ' '*')
|
||||||
|
|
||||||
|
echo -e "\n\n$border"
|
||||||
|
echo "* $text *"
|
||||||
|
echo "$border"
|
||||||
|
}
|
||||||
|
|
||||||
|
export APP_KEY=base64:$(openssl rand -base64 32)
|
||||||
|
draw_box $APP_KEY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "====================== Checking for updates... ====================== "
|
for dir in storage/framework/cache storage/framework/sessions storage/framework/views; do
|
||||||
/usr/bin/git pull
|
if [ ! -d "$dir" ]; then
|
||||||
|
echo -e "\n > $dir is missing. Creating scaffold for storage directory... "
|
||||||
echo "====================== Installing Composer dependencies... ====================== "
|
mkdir -p storage/framework/{cache,sessions,views}
|
||||||
/usr/local/bin/composer install
|
chmod -R 775 storage
|
||||||
|
chown -R www-data:www-data storage
|
||||||
echo "====================== Validating environment... ====================== "
|
fi
|
||||||
if [ $(stat -c '%U' .) != "www-data" ]; then
|
done
|
||||||
echo " > Setting correct permissions for pwd..."
|
|
||||||
chown -R www-data:www-data .
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ( ! grep -q "^APP_KEY=" ".env" || grep -q "^APP_KEY=$" ".env"); then
|
|
||||||
echo " > Ah, APP_KEY is missing in .env file. Generating a new key!"
|
|
||||||
|
|
||||||
/usr/local/bin/php artisan key:generate --force
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -L "public/storage" ]; then
|
if [ ! -L "public/storage" ]; then
|
||||||
echo " > Creating symbolic link for app public storage..."
|
echo -e "\n > Creating symbolic link for app public storage... "
|
||||||
|
|
||||||
/usr/local/bin/php artisan storage:link
|
/usr/local/bin/php /var/www/app/artisan storage:link
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "====================== Installing NPM dependencies and building frontend... ====================== "
|
echo -e "\n====================== Running migrations... ====================== "
|
||||||
/usr/bin/npm install
|
run_migrations() {
|
||||||
/usr/bin/npm run build
|
/usr/local/bin/php /var/www/app/artisan migrate --force
|
||||||
|
}
|
||||||
|
RETRIES=10
|
||||||
|
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... "
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "\n > Waiting for database to be ready... retrying in $DELAY seconds. "
|
||||||
|
sleep $DELAY
|
||||||
|
done
|
||||||
|
|
||||||
echo "====================== Running migrations... ====================== "
|
echo -e "\n====================== Spinning up Supervisor daemon... ====================== \n"
|
||||||
/usr/local/bin/php artisan migrate --force
|
|
||||||
|
|
||||||
echo "====================== Spinning up Supervisor daemon... ====================== "
|
|
||||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[mysqld]
|
|
||||||
cte_max_recursion_depth = 25000
|
|
||||||
+1
-1
@@ -14,7 +14,7 @@ server {
|
|||||||
fastcgi_param HTTPS $http_x_forwarded_proto;
|
fastcgi_param HTTPS $http_x_forwarded_proto;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
fastcgi_pass investbrain-app:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ /\.ht {
|
location ~ /\.ht {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# Redis RDB and AOF file location
|
|
||||||
dir /var/www/app/docker
|
|
||||||
+11
-18
@@ -1,41 +1,34 @@
|
|||||||
[supervisord]
|
[supervisord]
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
user=root
|
user=root
|
||||||
logfile=/var/log/supervisor/supervisord.log
|
|
||||||
pidfile=/var/run/supervisord.pid
|
pidfile=/var/run/supervisord.pid
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g 'daemon off;'
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
redirect_stderr=true
|
||||||
|
redirect_stdout=true
|
||||||
|
|
||||||
[program:php]
|
[program:php]
|
||||||
command=php-fpm -F
|
command=php-fpm -F
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/var/log/supervisor/php.log
|
redirect_stderr=true
|
||||||
stderr_logfile=/var/log/supervisor/php_error.log
|
redirect_stdout=true
|
||||||
|
|
||||||
[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]
|
[program:scheduler]
|
||||||
command=php artisan schedule:work
|
command=php artisan schedule:work
|
||||||
autorestart=true
|
autorestart=true
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
stdout_logfile=/dev/stdout
|
redirect_stdout=true
|
||||||
stdout_logfile_maxbytes=0
|
|
||||||
stderr_logfile=/dev/stderr
|
|
||||||
stderr_logfile_maxbytes=0
|
|
||||||
|
|
||||||
[program:queue-worker]
|
[program:queue-worker]
|
||||||
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
|
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
autorestart=true
|
autorestart=true
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
stdout_logfile=/dev/stdout
|
redirect_stdout=true
|
||||||
stdout_logfile_maxbytes=0
|
|
||||||
stderr_logfile=/dev/stderr
|
|
||||||
stderr_logfile_maxbytes=0
|
|
||||||
numprocs=2
|
numprocs=2
|
||||||
|
|
||||||
[supervisorctl]
|
[supervisorctl]
|
||||||
Generated
+479
-242
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user