From 12d19c0ea275c2fa1d155aec0e0b2681f41d5c48 Mon Sep 17 00:00:00 2001 From: Sergio Tanaka Date: Wed, 31 Dec 2025 09:35:14 -0300 Subject: [PATCH 1/5] Add docker compose --- README.md | 86 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 66 +++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 4ee04117d..b59f1b369 100644 --- a/README.md +++ b/README.md @@ -327,6 +327,92 @@ The final image includes: - `wealthfolio-server` binary at `/usr/local/bin/wealthfolio-server` - Alpine Linux base (small footprint) +### Using Docker Compose + +The easiest way to run Wealthfolio locally is using Docker Compose. A `docker-compose.yml` file is provided in the repository root. + +#### Quick Start + +1. **Set the secret key** (required for production): + +```bash +export WF_SECRET_KEY=$(openssl rand -base64 32) +``` + +2. **Start the service**: + +```bash +docker compose up -d +``` + +3. **Access the application**: + +Open your browser at `http://localhost:8088` + +#### Development Mode + +For development with CORS enabled for local Vite dev server: + +```bash +# Generate secret key and start dev service +export WF_SECRET_KEY=$(openssl rand -base64 32) && docker compose --profile dev up -d wealthfolio-dev +``` + +Or as a single command: + +```bash +WF_SECRET_KEY=$(openssl rand -base64 32) docker compose --profile dev up -d wealthfolio-dev +``` + +**Note:** The development profile requires `WF_SECRET_KEY` to be set. The service will not start without a valid base64-encoded 32-byte secret key. + +#### Useful Commands + +```bash +# View logs +docker compose logs -f + +# Stop the service +docker compose down + +# Stop and remove volumes (WARNING: deletes all data!) +docker compose down -v + +# Restart the service +docker compose restart + +# Check service status +docker compose ps +``` + +#### Configuration + +You can configure the service using environment variables. Create a `.env` file in the project root: + +```bash +WF_PORT=8088 +WF_SECRET_KEY=your-secret-key-here +WF_CORS_ALLOW_ORIGINS=* +``` + +Or set them inline: + +```bash +WF_SECRET_KEY=$(openssl rand -base64 32) docker compose up -d +``` + +#### Volumes + +Data is persisted in the `wealthfolio-data` Docker volume: +- Database: `/data/wealthfolio.db` (inside container) +- Secrets: `/data/secrets.json` (encrypted with `WF_SECRET_KEY`) + +To find the volume location on your host: + +```bash +docker volume inspect wealthfolio_wealthfolio-data +``` + ### Configuration You can configure the container using either: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..e13d76916 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,66 @@ +services: + wealthfolio: + image: afadil/wealthfolio:latest + container_name: wealthfolio + restart: unless-stopped + ports: + - "${WF_PORT:-8088}:8080" + volumes: + - wealthfolio-data:/data + environment: + # Server Configuration + - WF_LISTEN_ADDR=0.0.0.0:8080 + - WF_DB_PATH=/data/wealthfolio.db + - WF_STATIC_DIR=dist + - WF_CORS_ALLOW_ORIGINS=${WF_CORS_ALLOW_ORIGINS:-*} + - WF_REQUEST_TIMEOUT_MS=${WF_REQUEST_TIMEOUT_MS:-30000} + + # Security (required for production) + - WF_SECRET_KEY=${WF_SECRET_KEY:-} + + # Authentication (optional) + - WF_AUTH_PASSWORD_HASH=${WF_AUTH_PASSWORD_HASH:-} + - WF_AUTH_TOKEN_TTL_MINUTES=${WF_AUTH_TOKEN_TTL_MINUTES:-60} + + # Optional + - WF_SECRET_FILE=${WF_SECRET_FILE:-/data/secrets.json} + - WF_ADDONS_DIR=${WF_ADDONS_DIR:-} + healthcheck: + test: + [ + "CMD", + "wget", + "--quiet", + "--tries=1", + "--spider", + "http://localhost:8080/api/v1/healthz", + ] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + + # Development profile with CORS enabled for local Vite dev server + # Note: WF_SECRET_KEY must be provided via environment variable + # Use: export WF_SECRET_KEY=$(openssl rand -base64 32) && docker compose --profile dev up -d wealthfolio-dev + wealthfolio-dev: + image: afadil/wealthfolio:latest + container_name: wealthfolio-dev + restart: unless-stopped + ports: + - "${WF_PORT:-8088}:8080" + volumes: + - wealthfolio-data:/data + environment: + - WF_LISTEN_ADDR=0.0.0.0:8080 + - WF_DB_PATH=/data/wealthfolio.db + - WF_STATIC_DIR=dist + - WF_CORS_ALLOW_ORIGINS=http://localhost:1420,http://localhost:3000 + - WF_REQUEST_TIMEOUT_MS=30000 + - WF_SECRET_KEY=${WF_SECRET_KEY} + profiles: + - dev + +volumes: + wealthfolio-data: + driver: local From 2bcfdfb5934d60e4bdc0bfcf9746b53a7a966140 Mon Sep 17 00:00:00 2001 From: Sergio Tanaka Date: Wed, 31 Dec 2025 09:40:59 -0300 Subject: [PATCH 2/5] Add docker compose --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b59f1b369..2956c1fb7 100644 --- a/README.md +++ b/README.md @@ -732,14 +732,23 @@ Addons operate under a comprehensive permission system: ## Contributing -Contributions are welcome! Please follow these steps: - -1. Fork the repository. -2. Create a new branch (`git checkout -b feature-branch`). -3. Make your changes. -4. Commit your changes (`git commit -m 'Add some feature'`). -5. Push to the branch (`git push origin feature-branch`). -6. Open a pull request. +Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on: + +- Development workflow +- Pull request process +- Coding standards +- Testing requirements +- Commit guidelines + +Quick start: + +1. Fork the repository +2. Create a new branch (`git checkout -b feature/your-feature-name`) +3. Make your changes +4. Ensure tests pass and code builds +5. Submit a pull request + +For detailed information, please read [CONTRIBUTING.md](CONTRIBUTING.md). ## License From 2d5c386583eae7257523a46170847d68ec6e943c Mon Sep 17 00:00:00 2001 From: Sergio Tanaka Date: Wed, 31 Dec 2025 10:02:52 -0300 Subject: [PATCH 3/5] add build to docker compose --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++-- docker-compose.yml | 16 ++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2956c1fb7..43ea478bb 100644 --- a/README.md +++ b/README.md @@ -333,7 +333,9 @@ The easiest way to run Wealthfolio locally is using Docker Compose. A `docker-co #### Quick Start -1. **Set the secret key** (required for production): +**Option 1: Use pre-built image** (faster, recommended): + +1. **Set the secret key** (required): ```bash export WF_SECRET_KEY=$(openssl rand -base64 32) @@ -345,6 +347,27 @@ export WF_SECRET_KEY=$(openssl rand -base64 32) docker compose up -d ``` +**Option 2: Build from source** (for development or custom builds): + +1. **Set the secret key**: + +```bash +export WF_SECRET_KEY=$(openssl rand -base64 32) +``` + +2. **Build and start**: + +```bash +docker compose build +docker compose up -d +``` + +Or in a single command: + +```bash +WF_SECRET_KEY=$(openssl rand -base64 32) docker compose up -d --build +``` + 3. **Access the application**: Open your browser at `http://localhost:8088` @@ -353,15 +376,24 @@ Open your browser at `http://localhost:8088` For development with CORS enabled for local Vite dev server: +**Using pre-built image:** + ```bash # Generate secret key and start dev service export WF_SECRET_KEY=$(openssl rand -base64 32) && docker compose --profile dev up -d wealthfolio-dev ``` +**Building from source:** + +```bash +# Build and start dev service +export WF_SECRET_KEY=$(openssl rand -base64 32) && docker compose --profile dev build && docker compose --profile dev up -d wealthfolio-dev +``` + Or as a single command: ```bash -WF_SECRET_KEY=$(openssl rand -base64 32) docker compose --profile dev up -d wealthfolio-dev +WF_SECRET_KEY=$(openssl rand -base64 32) docker compose --profile dev up -d --build wealthfolio-dev ``` **Note:** The development profile requires `WF_SECRET_KEY` to be set. The service will not start without a valid base64-encoded 32-byte secret key. @@ -383,6 +415,12 @@ docker compose restart # Check service status docker compose ps + +# Rebuild the image (if building from source) +docker compose build + +# Rebuild and restart +docker compose up -d --build ``` #### Configuration diff --git a/docker-compose.yml b/docker-compose.yml index e13d76916..189a8091a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,12 @@ services: wealthfolio: - image: afadil/wealthfolio:latest + # Builds from source if image doesn't exist, or use --build flag to force rebuild + # To use pre-built image: docker compose up -d + # To build from source: docker compose up -d --build + image: ${DOCKER_IMAGE:-afadil/wealthfolio:latest} + build: + context: . + dockerfile: Dockerfile container_name: wealthfolio restart: unless-stopped ports: @@ -44,7 +50,13 @@ services: # Note: WF_SECRET_KEY must be provided via environment variable # Use: export WF_SECRET_KEY=$(openssl rand -base64 32) && docker compose --profile dev up -d wealthfolio-dev wealthfolio-dev: - image: afadil/wealthfolio:latest + # Builds from source if image doesn't exist, or use --build flag to force rebuild + # To use pre-built image: docker compose --profile dev up -d wealthfolio-dev + # To build from source: docker compose --profile dev up -d --build wealthfolio-dev + image: ${DOCKER_IMAGE:-afadil/wealthfolio:latest} + build: + context: . + dockerfile: Dockerfile container_name: wealthfolio-dev restart: unless-stopped ports: From 81a5aa902e2647177dacbef94f3c57fc073c5537 Mon Sep 17 00:00:00 2001 From: Sergio Tanaka Date: Wed, 31 Dec 2025 10:05:43 -0300 Subject: [PATCH 4/5] reverting contrib section --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 43ea478bb..77866975f 100644 --- a/README.md +++ b/README.md @@ -770,13 +770,14 @@ Addons operate under a comprehensive permission system: ## Contributing -Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on: - -- Development workflow -- Pull request process -- Coding standards -- Testing requirements -- Commit guidelines +Contributions are welcome! Please follow these steps: + +1. Fork the repository. +2. Create a new branch (`git checkout -b feature-branch`). +3. Make your changes. +4. Commit your changes (`git commit -m 'Add some feature'`). +5. Push to the branch (`git push origin feature-branch`). +6. Open a pull request. Quick start: From 843d7a8b70d5f389de734f2a706722b4aeb77ef5 Mon Sep 17 00:00:00 2001 From: Sergio Tanaka Date: Wed, 31 Dec 2025 10:06:09 -0300 Subject: [PATCH 5/5] reverting contrib section --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 77866975f..8acc93646 100644 --- a/README.md +++ b/README.md @@ -779,16 +779,6 @@ Contributions are welcome! Please follow these steps: 5. Push to the branch (`git push origin feature-branch`). 6. Open a pull request. -Quick start: - -1. Fork the repository -2. Create a new branch (`git checkout -b feature/your-feature-name`) -3. Make your changes -4. Ensure tests pass and code builds -5. Submit a pull request - -For detailed information, please read [CONTRIBUTING.md](CONTRIBUTING.md). - ## License This project is licensed under the AGPL-3.0 license. See the `LICENSE` file for