Running on Server
Configuration
Create backend/.env
and enter configuration variables
CSV_FILE_PATH=sample.csv # Note, leave empty if you want to disable
CSV_DATE_COLUMN=timestamp
CSV_DATE_COLUMN_FORMATTER=timestamp_formatter
POLYGON_IO_API_KEY=...
BINANCE_API_KEY=... # Note, you can use any string here, all Binance requests are public
BINANCE_API_SECRET=...
OPENAI_API_KEY=...
Note, see all env variables in backend/config.py
.
Building
Build the image:
Running locally
Run the image:
Navigate to http://localhost:8000
, you should see the application.
Running on server
Create DNS A records to link your server IP with the domain for your application.
Create docker-compose.yml
services:
traefik:
image: traefik:v3.1.2
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.myresolver.acme.email=tradiny@tradiny.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080" # Adds the dashboard port for easier debugging
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "letsencrypt:/letsencrypt"
restart: always
labels:
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
tradiny-populate:
image: tradiny-charts:latest
command: python3 populate.py
volumes:
- ./host:/app/host
profiles:
- populate
tradiny-charts:
image: tradiny-charts:latest
labels:
- "traefik.enable=true"
- "traefik.http.routers.tradiny-charts-http.rule=Host(`demo.tradiny.com`)" # HTTP router
- "traefik.http.routers.tradiny-charts-https.rule=Host(`demo.tradiny.com`)" # HTTPS router
- "traefik.http.services.tradiny-charts.loadbalancer.server.port=8000"
- "traefik.http.routers.tradiny-charts-http.entrypoints=web"
- "traefik.http.routers.tradiny-charts-http.middlewares=redirect-to-https"
- "traefik.http.routers.tradiny-charts-https.entrypoints=websecure"
- "traefik.http.routers.tradiny-charts-https.tls=true"
- "traefik.http.routers.tradiny-charts-https.tls.certresolver=myresolver"
restart: always
volumes:
- ./host:/app/host
Notice in this example
- We configure to run the application at
https://demo.tradiny.com
- We use Traefik proxy to manage HTTPS certificates.
Now, populate the DB:
Run the application in daemon mode:
Navigate to https://demo.tradiny.com
, you should see the application.
Preserving Changes
First, setup volume in your docker-compose.yml
Second,
- Setup
DB
env variable to/app/host/db.sqlite3
- Setup
VAPID_KEY_PATH
env variable to/app/host/private_key.pem