diff --git a/.cspell.config.json b/.cspell.config.json new file mode 100644 index 0000000..9b6862e --- /dev/null +++ b/.cspell.config.json @@ -0,0 +1,19 @@ +// cSpell Settings +{ + "version": "0.2", + "language": "en-GB", + + "dictionaries": [ + // Makes cSpell only use the British spelling of words + "!en_US" + ], + // List of words to be always considered correct + "words": [ + ], + // List of words to be always considered incorrect + // This is useful for offensive words and common spelling errors. + // For example "hte" should be "the" + "flagWords": [ + "hte" + ] +} diff --git a/.env b/.env index 40a3238..a84fbd1 100644 --- a/.env +++ b/.env @@ -1,11 +1,11 @@ ## See the "Settings" section in README.md for more details -## Set this to true if you're using a load balancer, or set it to false if you're using seperate IPs for each service. +## Set this to true if you're using a load balancer, or set it to false if you're using separate IPs for each service. ## If you're using monolithic (the default), leave this set to true USE_GENERIC_CACHE=true ## IP addresses that the lancache monolithic instance is reachable on -## Specify one or more IPs, space separated - these will be used when resolving DNS hostnames through lancachenet-dns. Multiple IPs can improve cache priming performance for some services (e.g. Steam)## IP Address that the lancache monolithic instance will run on +## Specify one or more IPs, space separated - these will be used when resolving DNS hostnames through lancachenet-dns. Multiple IPs can improve cache priming performance for some services (e.g. Steam) ## Note: This setting only affects DNS, monolithic and sniproxy will still bind to all IPs by default LANCACHE_IP=10.0.39.1 @@ -19,14 +19,25 @@ UPSTREAM_DNS=8.8.8.8 ## Note that by default, this will be a folder relative to the docker-compose.yml file CACHE_ROOT=./lancache -## Change this to customise the size of the memory cache (default 500m) -CACHE_MEM_SIZE=500m - -## Change this to customise the size of the disk cache (default 1000000m) -## If you have more storage, you'll likely want to increase this +## Change this to customise the maximum size of the disk cache (default 2000g). +## If you have more storage, you'll likely want to increase this. ## The cache server will prune content on a least-recently-used basis if it -## starts approaching this limit -CACHE_DISK_SIZE=1000000m +## starts approaching this limit. +CACHE_DISK_SIZE=2000g + +## Sets the minimum free disk space that must be kept at all times. +## When the available free space drops below the set amount for any reason, +## the cache server will begin pruning content to free up space. +## Prevents accidentally running out of disk space if CACHE_DISK_SIZE is set too high. +MIN_FREE_DISK=10g + +## Change this to allow sufficient index memory for the nginx cache manager (default 500m) +## We recommend 250m of index memory per 1TB of CACHE_DISK_SIZE +CACHE_INDEX_SIZE=500m ## Change this to limit the maximum age of cached content (default 3650d) -CACHE_MAX_AGE=3650d \ No newline at end of file +CACHE_MAX_AGE=3650d + +## Set the timezone for the docker containers, useful for correct timestamps on logs (default Europe/London) +## Formatted as tz database names. Example: Europe/Oslo or America/Los_Angeles +TZ=Europe/London diff --git a/README.md b/README.md index 227aa08..e54f37b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ ![Docker Pulls](https://img.shields.io/docker/pulls/lancachenet/monolithic?label=Monolithic) ![Docker Pulls](https://img.shields.io/docker/pulls/lancachenet/lancache-dns?label=Lancache-dns) ![Docker Pulls](https://img.shields.io/docker/pulls/lancachenet/sniproxy?label=Sniproxy) ![Docker Pulls](https://img.shields.io/docker/pulls/lancachenet/generic?label=Generic) -This docker-compose is meant as an example for running our lancache stack, It will run out of the box with minimal changes to the `.env` file for your local IP address. +This docker-compose is meant as an example for running our lancache stack, It will run out of the box with minimal changes to the `.env` file for your local IP address and disk settings. + +Once (and only once) you have a working system run `sudo ./enable_autostart.sh` to allow the containers to run at system startup # Settings > You *MUST* set at least `LANCACHE_IP` and `DNS_BIND_IP`. It is highly recommended that you change `CACHE_ROOT` to a folder of your choosing, and set [`CACHE_DISK_SIZE`](#cache_disk_size) to a value that suits your storage capacity. @@ -50,24 +52,36 @@ The `CACHE_ROOT` should either be on a separate partition, or ideally on separat > **Note:** this setting defaults to `./lancache`. Unless your cache storage lives here, you probably want to change this value. -## `CACHE_MEM_SIZE` -This controls the size of the memory cache used by the cache server. The default should suffice for almost all configurations. +## `CACHE_DISK_SIZE` +This setting will constrain the upper limit of space used by cached data. +The cache server will automatically delete cached data when the total stored amount approaches this limit, in a least-recently-used fashion (oldest data, least accessed deleted first). -> **Note:** this setting does not limit the amount of memory that the Linux host will use for page caches, only what the cache server will use itself - see the Docker documentation on limiting memory consumption for a container if you wish to constrain the total memory consumption of the cache server, but generally you want as much memory as possible on your cache server to be used to store hot data. +> **Note:** that this must be given in either: +> - gigabytes, with `g` suffix (e.g. the default value, `2000g`) +> - terabytes, with `t` suffix (e.g. `4t`) -## `CACHE_DISK_SIZE` -This setting will constrain the upper limit of space used by cached data. You generally want to leave a small gap (10-20GB at least) between the size listed here and the available storage space used for the cached data, just in case. +## `MIN_FREE_DISK` +Configures the minimum amount of free disk space that must be kept at all times. This setting avoids the scenario where the disk can accidentally become completely full, and no further data can be written. -The cache server will automatically cached data when the total stored amount approaches this limit, in a least-recently-used fashion (oldest data, least accessed deleted first). +When the available free space drops below the set amount for any reason, the cache server will begin pruning content in a least-recently-used fashion, similar to how `CACHE_DISK_SIZE` works. -> **Note:** that this must be given in megabytes with an `m` suffix (e.g. the default value, `1000000m`). +## `CACHE_INDEX_SIZE` +Change this to allow sufficient index memory for the nginx cache manager (default 500m) +We recommend 250m of index memory per 1TB of CACHE_DISK_SIZE + +> **Note:** this setting does not limit the amount of memory that the Linux host will use for page caches, only what the cache server will use itself - see the Docker documentation on limiting memory consumption for a container if you wish to constrain the total memory consumption of the cache server, but generally you want as much memory as possible on your cache server to be used to store hot data. ## `CACHE_MAX_AGE` This setting allows you to control the maximum duration cached data will be kept for. The default should be fine for most use cases - the `CACHE_DISK_SIZE` setting will generally be used before this for aging out data. > **Note:** this must be given as a number of days in age before expiry, with a `d` suffix (e.g. the default value, `3650d`). +## `TZ` +This setting allows you to set the timezone that is used by the docker containers. Most notably changing the timestamps of the logs. Useful for debugging without having to think sometimes multiple hours in the future/past. + +For a list of all timezones see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. + # More information The LanCache docker-stack is generated automatically from the data over at [UKLans](https://github.com/uklans/cache-domains). All services that are listed in the UKLans repository are available and supported inside this docker-compose. -For an FAQ see https://github.com/lancachenet/monolithic/blob/master/faq.md +For an FAQ see https://lancache.net/docs/faq/ diff --git a/docker-compose.yml b/docker-compose.yml index 65e6938..c96eed0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,30 @@ -version: '2' +x-restart-policy: &restart-policy "no" services: dns: image: lancachenet/lancache-dns:latest env_file: .env + restart: *restart-policy ports: - ${DNS_BIND_IP}:53:53/udp - sniproxy: - image: lancachenet/sniproxy:latest - env_file: .env - ports: - - 443:443/tcp + - ${DNS_BIND_IP}:53:53/tcp + +## HTTPS requests are now handled in monolithic directly +## you could choose to return to sniproxy if desired +# +# sniproxy: +# image: lancachenet/sniproxy:latest +# env_file: .env +# restart: *restart-policy +# ports: +# - 443:443/tcp + monolithic: image: lancachenet/monolithic:latest env_file: .env + restart: *restart-policy ports: - 80:80/tcp + - 443:443/tcp volumes: - ${CACHE_ROOT}/cache:/data/cache - ${CACHE_ROOT}/logs:/data/logs diff --git a/enable_autostart.sh b/enable_autostart.sh new file mode 100755 index 0000000..c9bae76 --- /dev/null +++ b/enable_autostart.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sed -i 's/x-restart-policy: \&restart-policy "no"/x-restart-policy: \&restart-policy "unless-stopped"/g' docker-compose.yml +docker-compose up -d diff --git a/update_containers.sh b/update_containers.sh index 291993a..d0cdc51 100644 --- a/update_containers.sh +++ b/update_containers.sh @@ -1,5 +1,5 @@ #!/bin/bash -docker-compose pull -docker-compose up -d +docker compose pull +docker compose up -d --remove-orphans