Docker Setup for Folio
This document provides instructions for running the Folio application using Docker.
Prerequisites
- Docker installed on your system
- Docker Compose (usually included with Docker Desktop)
Quick Start
Create a .env file (optional)
Copy the example environment file if you want to customize settings:
cp .env.example .env # Edit .env to customize settings if neededNote: Since we're using yfinance as the default data source, no API keys are required.
Build and run with Docker Compose
# Build and start the container in detached mode make docker-upAfter successful startup, you'll see a message with the URL where you can access the application.
Access the application
Open your browser and navigate to:
http://localhost:8050View logs
To monitor the application logs in real-time:
make docker-logsPress Ctrl+C to stop viewing logs.
Stop the application
make docker-down
Docker Commands Reference
The following Make commands are available for working with Docker:
| Command | Description |
|---|---|
make docker-build |
Build the Docker image |
make docker-run |
Run the Docker container |
make docker-up |
Start the application with docker-compose |
make docker-down |
Stop the docker-compose services |
make docker-logs |
Tail the Docker logs |
make docker-test |
Run tests in a Docker container |
Manual Docker Commands
If you prefer to use Docker directly without Make:
Build the Docker image
docker build -t folio:latest .Run the Docker container
docker run -p 8050:8050 --env-file .env folio:latestUse Docker Compose directly
# Start services docker-compose up -d # View logs docker-compose logs -f # Stop services docker-compose down
Troubleshooting
Port conflicts: If port 8050 is already in use, modify the
PORTenvironment variable in your.envfile and update the port mapping indocker-compose.yml.Data source: The application uses yfinance as the data source for stock data.
Volume mounting: If you're making changes to the code and want to see them reflected immediately, ensure the volumes in
docker-compose.ymlare correctly mapping your local directories.Dependencies: The Docker image uses
requirements.txtfor its dependencies. If you need to add or update dependencies, modify this file instead of editing the Dockerfile directly.Development dependencies: For development and testing, the Docker image can also install dependencies from
requirements-dev.txt. These are installed automatically when runningmake docker-test.API Keys: Sensitive data like API keys should be passed at runtime using environment variables or the
.envfile, not hardcoded in the Dockerfile.
Testing in Docker
To run tests in a Docker container:
make docker-test
This will build a Docker image with development dependencies and run the test suite inside the container.
Next Steps
After successfully running the application locally with Docker, you can consider:
- Setting up CI/CD with GitHub Actions
- Deploying to a hosting platform like Hugging Face Spaces
- Implementing additional Docker configurations for production environments