diff --git a/.markdownlint.yml b/.markdownlint.yml index 8d734f60..c7fd0a7d 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,2 +1 @@ -{ "default": true, "MD013": false, "MD033": false } - +{ "default": true, "MD013": false, "MD033": false } \ No newline at end of file diff --git a/services/garage/.env b/services/garage/.env new file mode 100644 index 00000000..688611c4 --- /dev/null +++ b/services/garage/.env @@ -0,0 +1,24 @@ +#version=1.1 +#URL=https://github.com/tailscale-dev/ScaleTail +#COMPOSE_PROJECT_NAME= # Optional: only use when running multiple deployments on the same infrastructure. + +# Service Configuration +SERVICE=garage # Service name (e.g., adguard). Used as hostname in Tailscale and for container naming (app-${SERVICE}). +IMAGE_URL=dxflrs/garage:v2.3.0 # Docker image URL from container registry (e.g., adguard/adguard-home). + +# Network Configuration +# SERVICEPORT= # Port to expose to local network. Uncomment the "ports:" section in compose.yaml to enable. +DNS_SERVER=9.9.9.9 # Preferred DNS server for Tailscale. Uncomment the "dns:" section in compose.yaml to enable. + +# Tailscale Configuration +TS_AUTHKEY= # Auth key from https://tailscale.com/admin/authkeys. See: https://tailscale.com/kb/1085/auth-keys#generate-an-auth-key for instructions. + +# Optional Service variables +# PUID=1000 + +#Time Zone setting for containers +TZ=Europe/Amsterdam # See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + +# Any Container environment variables are declared below. See https://docs.docker.com/compose/how-tos/environment-variables/ + +#EXAMPLE_VAR="Environment varibale" diff --git a/services/garage/README.md b/services/garage/README.md new file mode 100644 index 00000000..7cec6015 --- /dev/null +++ b/services/garage/README.md @@ -0,0 +1,26 @@ +# Garage with Tailscale Sidecar Configuration + +This Docker Compose configuration sets up [**Garage**](https://garagehq.deuxfleurs.fr/) with tailscale as a sidecar container. Allowing you to securely host your own S3 compatible backend on your tailnet + +## Garage + +[**Garage**](https://garagehq.deuxfleurs.fr/) is an S3 compatible storage solution designed for self hosting at a small scale. Supporting Geo-replication and redundancy optimised for performance and resiliance to node failures. + +## Key Features + +- S3 API +- Geo-distribution +- Flexible deployments +- Multiple replication modes +- Compression & Deduplication +- And many more [**here**](https://garagehq.deuxfleurs.fr/documentation/reference-manual/features/) + +## Configuration Overview + +In this deployment, the `tailscale-garage` service runs the Tailscale client to establish a secure private network. The `garage` container uses `network_mode: service:tailscale-garage` to route its traffic through the Tailscale interface. This ensures that all garage api routes are only accessible securely through your tailnet. + +## Files to check + +Please check the following contents for validity as some variables need to be defined upfront. + +- `.env` // Main variable `TS_AUTHKEY` and `TZ` for timezone config diff --git a/services/garage/compose.yaml b/services/garage/compose.yaml new file mode 100644 index 00000000..d7fb7de1 --- /dev/null +++ b/services/garage/compose.yaml @@ -0,0 +1,75 @@ +configs: + ts-serve: + content: | + {"TCP":{"443":{"HTTPS":true}}, + "Web":{"$${TS_CERT_DOMAIN}:443": + "Handlers": { + "/": { + "Proxy": "http://127.0.0.1:3900" + "AllowFunnel":{"$${TS_CERT_DOMAIN}:443":false}} + + +services: +# Make sure you have updated/checked the .env file with the correct variables. +# All the ${ xx } need to be defined there. + # Tailscale Sidecar Configuration + tailscale: + image: tailscale/tailscale:latest # Image to be used + container_name: tailscale-${SERVICE} # Name for local container management + hostname: ${SERVICE} # Name used within your Tailscale environment + environment: + - TS_AUTHKEY=${TS_AUTHKEY} + - TS_STATE_DIR=/var/lib/tailscale + - TS_SERVE_CONFIG=/config/serve.json # Tailscale Serve configuration to expose the web interface on your local Tailnet - remove this line if not required + - TS_USERSPACE=false + - TS_ENABLE_HEALTH_CHECK=true # Enable healthcheck endpoint: "/healthz" + - TS_LOCAL_ADDR_PORT=127.0.0.1:41234 # The : for the healthz endpoint + #- TS_ACCEPT_DNS=true # Uncomment when using MagicDNS + - TS_AUTH_ONCE=true + configs: + - source: ts-serve + target: /config/serve.json + volumes: + - ./config:/config # Config folder used to store Tailscale files - you may need to change the path + - ./ts/state:/var/lib/tailscale # Tailscale requirement - you may need to change the path + devices: + - /dev/net/tun:/dev/net/tun # Network configuration for Tailscale to work + cap_add: + - net_admin # Tailscale requirement + #ports: + # - 0.0.0.0:${SERVICEPORT}:${SERVICEPORT} # Binding port ${SERVICE}PORT to the local network - may be removed if only exposure to your Tailnet is required + # If any DNS issues arise, use your preferred DNS provider by uncommenting the config below + #dns: + # - ${DNS_SERVER} + healthcheck: + test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz"] # Check Tailscale has a Tailnet IP and is operational + interval: 1m # How often to perform the check + timeout: 10s # Time to wait for the check to succeed + retries: 3 # Number of retries before marking as unhealthy + start_period: 10s # Time to wait before starting health checks + restart: always + + # ${SERVICE} + application: + image: ${IMAGE_URL} # Image to be used + network_mode: service:tailscale # Sidecar configuration to route ${SERVICE} through Tailscale + container_name: app-${SERVICE} # Name for local container management + environment: # Varibles are delared in .env file. + - PUID=1000 + - PGID=1000 + - TZ=${TZ} + #- EXAMPLE_VAR=${EXAMPLE_VAR} + volumes: + - ./garage.toml:/etc/garage.toml + - ./${SERVICE}-data:/var/lib/garage/data + - ./${SERVICE}-meta:/var/lib/garage/meta + depends_on: + tailscale: + condition: service_healthy + healthcheck: + test: ["CMD", "pgrep", "-f", "${SERVICE}"] # Check if ${SERVICE} process is running + interval: 1m # How often to perform the check + timeout: 10s # Time to wait for the check to succeed + retries: 3 # Number of retries before marking as unhealthy + start_period: 30s # Time to wait before starting health checks + restart: always diff --git a/services/garage/garage.toml b/services/garage/garage.toml new file mode 100644 index 00000000..cf9f832f --- /dev/null +++ b/services/garage/garage.toml @@ -0,0 +1,24 @@ +metadata_dir = "/tmp/meta" +data_dir = "/tmp/data" +db_engine = "sqlite" + +replication_factor = 1 + +rpc_bind_addr = "[::]:3901" +rpc_public_addr = "127.0.0.1:3901" +rpc_secret = "$(openssl rand -hex 32)" + +[s3_api] +s3_region = "garage" +api_bind_addr = "[::]:3900" +root_domain = ".s3.garage.localhost" + +[s3_web] +bind_addr = "[::]:3902" +root_domain = ".web.garage.localhost" +index = "index.html" + +[admin] +api_bind_addr = "[::]:3903" +admin_token = "$(openssl rand -base64 32)" +metrics_token = "$(openssl rand -base64 32)" \ No newline at end of file