Skip to content

Commit

Permalink
feat: [torrust#2] new example config for dropplet
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Dec 11, 2023
1 parent 87c7884 commit f5c0203
Show file tree
Hide file tree
Showing 13 changed files with 583 additions and 0 deletions.
15 changes: 15 additions & 0 deletions droplet/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
USER_ID=1000

# Index GUI
TORRUST_INDEX_GUI_API_BASE_URL=http://index.torrust-demo.com/api/v1
NITRO_HOST=0.0.0.0
NITRO_PORT=3000

# Index
TORRUST_INDEX_CONFIG=
TORRUST_INDEX_TRACKER_API_TOKEN=MyAccessToken
TORRUST_INDEX_API_CORS_PERMISSIVE=false

# Tracker
TORRUST_TRACKER_CONFIG=
TORRUST_TRACKER_API_ADMIN_TOKEN=MyAccessToken
3 changes: 3 additions & 0 deletions droplet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
.storage/
storage/
50 changes: 50 additions & 0 deletions droplet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Droplet configuration

It's a sample production configuration to deploy the Index on a Digital Ocean droplet.

Please, refer to each project's README for more information about how to run them using docker.

## Requirements

- Docker version 24.0.7, build afdd53b.
- Docker Compose version v2.3.3.
- GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu).

## Install

```s
mkdir ~/Tmp && cd ~/Tmp
git clone [email protected]:torrust/torrust-compose.git
cd torrust-compose/droplet
./bin/install.sh
```

## Usage

To start the application:

```s
./bin/start.sh
```

To stop the application:

```s
./bin/stop.sh
```

By default, the application will:

- Be available at <http://localhost:3000>.
- Use the `./storage/database` directory to store the data.
- Use SQLite as the database engine.

After starting the application you should see these running containers:

```s
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86d707f00a2e torrust/index-gui:develop "/usr/local/bin/entry_point_sh…" 16 minutes ago Up About a minute (healthy) 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp torrust-index-gui-1
9dc3dca96ee5 torrust/index:develop "/usr/local/bin/entry_point_sh…" 16 minutes ago Up About a minute (healthy) 0.0.0.0:3001->3001/tcp, :::3001->3001/tcp torrust-index-1
09833196d645 torrust/tracker:develop "/usr/local/bin/entry_point_sh…" 16 minutes ago Up About a minute (healthy) 0.0.0.0:1212->1212/tcp, :::1212->1212/tcp, 0.0.0.0:7070->7070/tcp, :::7070->7070/tcp, 1313/tcp, 0.0.0.0:6969->6969/udp, :::6969->6969/udp torrust-tracker-1
```
56 changes: 56 additions & 0 deletions droplet/bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

if ! [ -f "./.env" ]; then
echo "Creating compose .env './.env'"
cp .env.production .env
fi

## Proxy

mkdir -p ./storage/proxy/etc/nginx-conf
mkdir -p ./storage/proxy/webroot
mkdir -p ./storage/dhparam

if ! [ -f "./storage/proxy/etc/nginx-conf/nginx.conf" ]; then
echo "Creating proxy config file: './storage/proxy/etc/nginx-conf/nginx.conf'"
cp ./share/container/default/config/nginx.80.conf ./storage/proxy/etc/nginx-conf/nginx.conf
fi

## Certbot

mkdir -p ./storage/certbot/etc
mkdir -p ./storage/certbot/lib

## Index

# Generate the Index sqlite database directory and file if it does not exist
mkdir -p ./storage/index/lib/database

if ! [ -f "./storage/index/lib/database/sqlite3.db" ]; then
echo "Creating index database: './storage/index/lib/database/sqlite3.db'"
sqlite3 "./storage/index/lib/database/sqlite3.db" "VACUUM;"
fi

mkdir -p ./storage/index/etc

if ! [ -f "./storage/index/etc/index.prod.container.sqlite3.toml" ]; then
echo "Crating index configuration: './storage/index/etc/index.toml'"
cp ./share/container/default/config/index.prod.container.sqlite3.toml ./storage/index/etc/index.toml
fi

## Tracker

# Generate the Tracker sqlite database directory and file if it does not exist
mkdir -p ./storage/tracker/lib/database

if ! [ -f "./storage/tracker/lib/database/sqlite3.db" ]; then
echo "Creating tracker database: './storage/tracker/lib/database/sqlite3.db'"
sqlite3 "./storage/tracker/lib/database/sqlite3.db" "VACUUM;"
fi

mkdir -p ./storage/tracker/etc

if ! [ -f "./storage/tracker/etc/tracker.prod.container.sqlite3.toml" ]; then
echo "Crating tracker configuration: './storage/tracker/etc/tracker.toml'"
cp ./share/container/default/config/tracker.prod.container.sqlite3.toml ./storage/tracker/etc/tracker.toml
fi
3 changes: 3 additions & 0 deletions droplet/bin/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose restart
10 changes: 10 additions & 0 deletions droplet/bin/ssl_renew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

COMPOSE="/usr/bin/docker compose --ansi never"
DOCKER="/usr/bin/docker"

cd /home/torrust/github/torrust/torrust-compose/droplet || exit

$COMPOSE run certbot renew --dry-run && $COMPOSE kill -s SIGHUP proxy

$DOCKER system prune -af
7 changes: 7 additions & 0 deletions droplet/bin/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

TORRUST_INDEX_CONFIG_PATH=$(cat ./storage/index/etc/index.toml) \
TORRUST_TRACKER_CONFIG_PATH=$(cat ./storage/tracker/etc/tracker.toml) \
TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken} \
docker compose up --build --detach

4 changes: 4 additions & 0 deletions droplet/bin/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker compose down

104 changes: 104 additions & 0 deletions droplet/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
name: torrust
services:

certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./storage/proxy/webroot:/var/www/html
- ./storage/certbot/etc:/etc/letsencrypt
- ./storage/certbot/lib:/var/lib/letsencrypt
depends_on:
- proxy

proxy:
image: nginx:mainline-alpine
container_name: proxy
restart: unless-stopped
networks:
- frontend_network
- backend_network
ports:
- "80:80"
- "443:443"
volumes:
- ./storage/proxy/webroot:/var/www/html
- ./storage/proxy/etc/nginx-conf:/etc/nginx/conf.d
- ./storage/certbot/etc:/etc/letsencrypt
- ./storage/certbot/lib:/var/lib/letsencrypt
- ./storage/dhparam:/etc/ssl/certs
depends_on:
- index-gui
- index
- tracker

index-gui:
image: torrust/index-gui:develop
container_name: index-gui
tty: true
restart: unless-stopped
environment:
- USER_ID=${USER_ID}
- NUXT_PUBLIC_API_BASE=${TORRUST_INDEX_GUI_API_BASE_URL:-http://localhost:3001/v1}
- NITRO_HOST=${NITRO_HOST:-0.0.0.0}
- NITRO_PORT=${NITRO_PORT:-3000}
networks:
- frontend_network
ports:
- 3000:3000
volumes:
- ./storage/index-gui/log:/var/log/torrust/index-gui:Z
depends_on:
- index
- tracker

index:
image: torrust/index:develop
container_name: index
tty: true
restart: unless-stopped
environment:
- USER_ID=${USER_ID}
- TORRUST_INDEX_DATABASE=${TORRUST_INDEX_DATABASE:-sqlite3}
- TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_INDEX_DATABASE_DRIVER:-sqlite3}
- TORRUST_INDEX_TRACKER_API_TOKEN=${TORRUST_INDEX_TRACKER_API_TOKEN:-MyAccessToken}
- TORRUST_INDEX_API_CORS_PERMISSIVE=${TORRUST_INDEX_API_CORS_PERMISSIVE:-true}
networks:
- backend_network
ports:
- 3001:3001
volumes:
- ./storage/index/lib:/var/lib/torrust/index:Z
- ./storage/index/log:/var/log/torrust/index:Z
- ./storage/index/etc:/etc/torrust/index:Z
depends_on:
- tracker

tracker:
image: torrust/tracker:develop
container_name: tracker
tty: true
restart: unless-stopped
environment:
- USER_ID=${USER_ID}
- TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-sqlite3}
- TORRUST_TRACKER_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER:-sqlite3}
- TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken}
networks:
- backend_network
ports:
- 6969:6969/udp
- 7070:7070
- 1212:1212
volumes:
- ./storage/tracker/lib:/var/lib/torrust/tracker:Z
- ./storage/tracker/log:/var/log/torrust/tracker:Z
- ./storage/tracker/etc:/etc/torrust/tracker:Z

networks:
frontend_network: {}
backend_network: {}

volumes:
mysql_data: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
log_level = "info"

[website]
name = "Torrust"

# Please override the tracker token setting the
# `TORRUST_INDEX_TRACKER_API_TOKEN`
# environmental variable!

[tracker]
url = "udp://tracker.torrust-demo.com:6969"
mode = "Public"
api_url = "http://tracker:1212"
token = "MyAccessToken"
token_valid_seconds = 7257600

[net]
port = 3001

[auth]
email_on_signup = "Optional"
min_password_length = 6
max_password_length = 64
secret_key = "MaxVerstappenWC2021"

[database]
connect_url = "sqlite:///var/lib/torrust/index/database/sqlite3.db?mode=rwc"

[mail]
email_verification_enabled = false
from = "[email protected]"
reply_to = "[email protected]"
username = ""
password = ""
server = "mailcatcher"
port = 1025

[image_cache]
max_request_timeout_ms = 1000
capacity = 128000000
entry_size_limit = 4000000
user_quota_period_seconds = 3600
user_quota_bytes = 64000000

[api]
default_torrent_page_size = 10
max_torrent_page_size = 30

[tracker_statistics_importer]
torrent_info_update_interval = 3600
port = 3002
Loading

0 comments on commit f5c0203

Please sign in to comment.