feat: add copyparty
This commit is contained in:
85
modules/20-services-apps/copyparty/README.md
Normal file
85
modules/20-services-apps/copyparty/README.md
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
# Copyparty Module
|
||||||
|
|
||||||
|
This module deploys [copyparty](https://github.com/9001/copyparty), a portable file server.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The copyparty module:
|
||||||
|
|
||||||
|
- Deploys one Docker container: `copyparty`.
|
||||||
|
- Mounts a volume for configuration and another for the files to be shared.
|
||||||
|
- Provides a service definition for integration with networking modules.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "copyparty" {
|
||||||
|
source = "./modules/20-services-apps/copyparty"
|
||||||
|
fileshare_path = "/path/to/your/fileshare/top/folder"
|
||||||
|
config_path = "/path/to/copyparty/config"
|
||||||
|
networks = ["homelab-network"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
| ---------------- | ----------------------------------------------------------- |
|
||||||
|
| `image_tag` | Tag of the copyparty image to use |
|
||||||
|
| `fileshare_path` | Host path for the top folder of the file share |
|
||||||
|
| `config_path` | Host path for copyparty configuration files |
|
||||||
|
| `networks` | List of additional networks to which copyparty should be attached |
|
||||||
|
| `puid` | User ID to run the container as |
|
||||||
|
| `pgid` | Group ID to run the container as |
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
| Output | Description |
|
||||||
|
| -------------------- | ---------------------------------------------------------- |
|
||||||
|
| `service_definition` | Service definition for integration with networking modules |
|
||||||
|
|
||||||
|
## Service Definition
|
||||||
|
|
||||||
|
This module outputs a service definition that is used by the networking modules to expose the service.
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
{
|
||||||
|
name = "copyparty"
|
||||||
|
primary_port = 3923
|
||||||
|
endpoint = "http://copyparty:3923"
|
||||||
|
subdomains = ["files"]
|
||||||
|
publish_via = "reverse_proxy"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Data Persistence
|
||||||
|
|
||||||
|
Copyparty uses two volumes:
|
||||||
|
|
||||||
|
1. Configuration: `/cfg` in the container, mapped to `var.config_path` on the host.
|
||||||
|
2. File Share: `/w` in the container, mapped to `var.fileshare_path` on the host.
|
||||||
|
|
||||||
|
## Integration with Networking Modules
|
||||||
|
|
||||||
|
This service is configured to be exposed through the Caddy reverse proxy, set by `publish_via = "reverse_proxy"`.
|
||||||
|
|
||||||
|
## Example Integration in Main Configuration
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "copyparty" {
|
||||||
|
source = "./modules/20-services-apps/copyparty"
|
||||||
|
fileshare_path = "/mnt/storage/files"
|
||||||
|
config_path = "${module.system_globals.volume_host}/copyparty/config"
|
||||||
|
networks = [module.services.homelab_docker_network_name]
|
||||||
|
}
|
||||||
|
|
||||||
|
# The service definition is automatically included in the services output
|
||||||
|
module "services" {
|
||||||
|
source = "./modules/services"
|
||||||
|
# ...
|
||||||
|
service_definitions = [
|
||||||
|
module.copyparty.service_definition,
|
||||||
|
# Other service definitions
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
89
modules/20-services-apps/copyparty/main.tf
Normal file
89
modules/20-services-apps/copyparty/main.tf
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
variable "image_tag" {
|
||||||
|
description = "The tag for the copyparty container image"
|
||||||
|
type = string
|
||||||
|
default = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "fileshare_path" {
|
||||||
|
description = "Path to the top folder of the file share"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "config_path" {
|
||||||
|
description = "Path to the configuration files for copyparty"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "networks" {
|
||||||
|
description = "List of networks to which the container should be attached"
|
||||||
|
type = list(string)
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "puid" {
|
||||||
|
description = "User ID to run the container as"
|
||||||
|
type = string
|
||||||
|
default = "1000"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pgid" {
|
||||||
|
description = "Group ID to run the container as"
|
||||||
|
type = string
|
||||||
|
default = "1000"
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
container_name = "copyparty"
|
||||||
|
image = "copyparty/ac"
|
||||||
|
tag = var.image_tag
|
||||||
|
monitoring = true
|
||||||
|
internal_port = 3923
|
||||||
|
user = "${var.puid}:${var.pgid}"
|
||||||
|
volumes = [
|
||||||
|
{
|
||||||
|
host_path = var.config_path
|
||||||
|
container_path = "/cfg"
|
||||||
|
read_only = false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
host_path = var.fileshare_path
|
||||||
|
container_path = "/w"
|
||||||
|
read_only = false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
env_vars = {
|
||||||
|
LD_PRELOAD = "/usr/lib/libmimalloc-secure.so.2"
|
||||||
|
PYTHONUNBUFFERED = "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module "copyparty" {
|
||||||
|
source = "../../10-services-generic/docker-service"
|
||||||
|
container_name = local.container_name
|
||||||
|
image = local.image
|
||||||
|
tag = local.tag
|
||||||
|
user = local.user
|
||||||
|
volumes = local.volumes
|
||||||
|
env_vars = local.env_vars
|
||||||
|
networks = var.networks
|
||||||
|
monitoring = local.monitoring
|
||||||
|
destroy_grace_seconds = 15
|
||||||
|
ports = [
|
||||||
|
{
|
||||||
|
internal = local.internal_port
|
||||||
|
external = local.internal_port
|
||||||
|
protocol = "tcp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
output "service_definition" {
|
||||||
|
description = "General service definition with optional ingress configuration"
|
||||||
|
value = {
|
||||||
|
name = local.container_name
|
||||||
|
primary_port = local.internal_port
|
||||||
|
endpoint = "http://${local.container_name}:${local.internal_port}"
|
||||||
|
subdomains = ["drive"]
|
||||||
|
publish_via = "tunnel"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,13 @@ module "calibre" {
|
|||||||
networks = [module.homelab_docker_network.name]
|
networks = [module.homelab_docker_network.name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "copyparty" {
|
||||||
|
source = "${local.module_dir}/20-services-apps/copyparty"
|
||||||
|
fileshare_path = "${local.root_volume}"
|
||||||
|
config_path = "${local.volume_host}/copyparty"
|
||||||
|
networks = [module.homelab_docker_network.name]
|
||||||
|
}
|
||||||
|
|
||||||
module "crawl4ai" {
|
module "crawl4ai" {
|
||||||
source = "${local.module_dir}/20-services-apps/crawl4ai"
|
source = "${local.module_dir}/20-services-apps/crawl4ai"
|
||||||
volume_path = "${local.volume_host}/crawl4ai"
|
volume_path = "${local.volume_host}/crawl4ai"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ output "service_definitions" {
|
|||||||
module.actualbudget.service_definition,
|
module.actualbudget.service_definition,
|
||||||
module.affine.service_definition,
|
module.affine.service_definition,
|
||||||
module.calibre.service_definition,
|
module.calibre.service_definition,
|
||||||
|
module.copyparty.service_definition,
|
||||||
module.crawl4ai.service_definition,
|
module.crawl4ai.service_definition,
|
||||||
module.emulatorjs.service_definition,
|
module.emulatorjs.service_definition,
|
||||||
module.glance.service_definition,
|
module.glance.service_definition,
|
||||||
|
|||||||
Reference in New Issue
Block a user