Skip to content

Commit

Permalink
Merge pull request #52 from investbrainapp/optimize-dockerfile
Browse files Browse the repository at this point in the history
Optimize Docker Image
  • Loading branch information
hackeresq authored Jan 27, 2025
2 parents 8dd153f + 778d799 commit bdd30c2
Show file tree
Hide file tree
Showing 15 changed files with 835 additions and 550 deletions.
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ tests
.DS_Store
vapor.yml
.vapor
storage
storage/app/livewire-tmp/*
storage/app/public/profile-photos/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/testing/*
storage/framework/views/*
storage/framework/logs/*
33 changes: 24 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
APP_NAME=Investbrain
APP_ENV=production
# Generate a secure key using `openssl rand -base64 32`
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC

# Port for NGINX to listen on
APP_PORT=8000

# Used internally to generate absolute links
APP_URL="http://localhost:${APP_PORT}"
SELF_HOSTED=true
REGISTRATION_ENABLED=true

# ASSET_URL="http://localhost:8000" # (optional) webroot for static assets (css, js, images, etc)
# Webroot for static assets (css, js, images, etc)
ASSET_URL="${APP_URL}"

# Enables or disables new user registration
REGISTRATION_ENABLED=true

# Enable or disable AI chat feature
AI_CHAT_ENABLED=false

# API key for OpenAI (for Llama support, see docs)
OPENAI_API_KEY=
OPENAI_ORGANIZATION=

# Market data provider to use (comma separated list)
MARKET_DATA_PROVIDER=yahoo
MARKET_DATA_REFRESH=30
ALPHAVANTAGE_API_KEY=
FINNHUB_API_KEY=

# Cadence to refresh market data (in minutes)
MARKET_DATA_REFRESH=30
DAILY_CHANGE_TIME=

#### Advanced configurations ####
ENABLED_LOGIN_PROVIDERS=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
Expand All @@ -29,9 +40,13 @@ LINKEDIN_CLIENT_SECRET=
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=

APP_NAME=Investbrain
APP_TIMEZONE=UTC
APP_ENV=production
APP_DEBUG=true
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
SELF_HOSTED=true

DB_CONNECTION=mysql
DB_HOST=investbrain-mysql
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ Investbrain is a Laravel PHP web application that leverages Livewire and Tailwin

## 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!

First, you can clone this repository:
**1. Copy Docker Compose file**

```bash
git clone https://github.com/investbrainapp/investbrain.git && cd investbrain
```
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.

Then, build the Docker image and bring up the container (this will take a few minutes):
**2. Set your environment**

```bash
docker compose up
```
Adjust the `environment` properties in the Docker Compose file to your preferences.

_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.

> 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.
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`.
**3. Run `docker compose up`**

If everything worked as expected, you should now be able to access Investbrain in the browser at. You should create an account by visiting:
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
http://localhost:8000/register
Expand Down Expand Up @@ -135,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_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 |
| ALPHAVANTAGE_API_KEY | If using the Alpha Vantage provider | `null` |
| FINNHUB_API_KEY | If using the Finnhub provider | `null` |
Expand All @@ -149,7 +150,7 @@ There are several optional configurations available when installing using the re
| 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

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"keywords": ["stocks", "dividends", "investments", "tracking"],
"license": "CC-BY-NC 4.0",
"require": {
"php": "^8.2",
"php": "^8.3",
"ext-gd": "*",
"ext-mbstring": "*",
"ext-zip": "*",
"finnhub/client": "master@dev",
"laravel/framework": "^11.35",
"laravel/jetstream": "^5.1",
Expand Down
Loading

0 comments on commit bdd30c2

Please sign in to comment.