Skip to content

Commit

Permalink
Merge pull request #55 from investbrainapp/optimize-dockerfile
Browse files Browse the repository at this point in the history
workflow: Downgrade github runner to Ubunutu 22.04
  • Loading branch information
hackeresq authored Jan 27, 2025
2 parents d317c03 + 307f65c commit 000c459
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/build-and-push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04 #ubuntu-latest
steps:
- name: Increase swap space
run: sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=5120 && sudo chmod 600 /var/swap.1 && sudo /sbin/mkswap /var/swap.1 && sudo /sbin/swapon /var/swap.1

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -29,9 +32,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Increase swap space
run: sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=4096 && sudo /sbin/mkswap /var/swap.1 && sudo /sbin/swapon /var/swap.1

- name: Cache Docker layers
uses: actions/cache@v4
with:
Expand All @@ -55,6 +55,4 @@ jobs:
investbrainapp/investbrain:latest
investbrainapp/investbrain:${{ env.version }}
ghcr.io/investbrainapp/investbrain:latest
ghcr.io/investbrainapp/investbrain:${{ env.version }}
ghcr.io/investbrainapp/investbrain:${{ env.version }}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Grab a copy of the [docker-compose.yml](https://github.com/investbrainapp/invest

**2. Set your environment**

Adjust the `environment` properties in the Docker Compose file to your preferences.
Adjust the `environment` properties in the Docker Compose file to your preferences. Alternatively, create a .env file in the same directory as your compose file, then reference the .env file using the `env_file` property.

_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.
_Importantly_, you need to set the `APP_KEY` value to a complex random value. If you're unsure, Investbrain will generate an `APP_KEY` for you on first run - but you must **manually** update your environment configuration with this generated value!

> 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.
> Tip: Want to know what other configuration 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:
This might take a few minutes to pull the Docker images. But assuming everything worked as expected, you should now be able to access Investbrain in the browser by visiting:

```bash
http://localhost:8000/register
Expand All @@ -76,15 +76,15 @@ Investbrain includes an extensible market data provider interface that allows yo

### Configuration

You can specify the market data provider you want to use in your .env file:
You can specify the market data provider you want to use in your environment variables:

```bash
MARKET_DATA_PROVIDER=yahoo
```

You can also use Investbrain's built-in fallback mechanism to ensure reliable data access. If any provider fails, Investbrain will automatically attempt to retrieve data from the next available provider, continuing through your configured providers until one returns successfully.

Your selected providers should be listed in your .env file. Each should be separated by a comma:
Your selected providers should be listed in your environment variables. Each should be separated by a comma:

```bash
MARKET_DATA_PROVIDER=yahoo,alphavantage
Expand Down Expand Up @@ -129,7 +129,7 @@ Exporting your portfolios and transactions is a convenient way to back-up your I

## Configuration

There are several optional configurations available when installing using the recommended [Docker method](#self-hosting). These options are configurable using an environment file. Changes can be made in your [.env](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file before installation.
There are several optional configurations available when installing using the recommended [Docker method](#self-hosting). These options are configurable using an environment file. Configurations can be added to your [.env](https://github.com/investbrainapp/investbrain/blob/main/.env.example) file or to the `environment` property in the [docker-compose.yml](https://github.com/investbrainapp/investbrain/blob/main/docker-compose.yml) file.

| Option | Description | Default |
| ------------- | ------------- | ------------- |
Expand All @@ -150,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 and are cached during run-time. If change any .env values, you'll have to restart the 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 environment configurations, you'll have to restart the container before your changes take effect.
## Updating

Expand All @@ -160,10 +160,10 @@ To update Investbrain using the recommended [Docker installation](#self-hosting)
docker compose stop
```

Then pull the latest updates from this repository using git:
Then pull the latest Docker image:

```bash
git pull
docker image pull investbrainapp/investbrain:latest
```

Finally bring the containers back up!
Expand Down
36 changes: 19 additions & 17 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,42 @@ ENV SELF_HOSTED=true
COPY . /var/www/app
WORKDIR /var/www/app

# Install common php extension dependencies
RUN apt-get update && apt-get install -y \
# Allow PHP installs to be built cross-platform
#ENV CFLAGS="-fstack-protector-strong -fpic -fPIC -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

# Install required packages
RUN apt-get update && apt-get upgrade -y \
&& apt-get upgrade -y \
nginx \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
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 zip pdo_mysql mysqli intl \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
gd pgsql zip pdo_mysql mysqli intl

# Set permissions
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
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 \
# 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

# Remove default nginx config
Expand Down

0 comments on commit 000c459

Please sign in to comment.