did something

This commit is contained in:
iamBadgers
2026-04-01 19:20:43 -07:00
parent d71d698888
commit bc95e49269
2 changed files with 7 additions and 6 deletions

View File

@@ -1,7 +1,8 @@
import docker import docker
from game_tables import GameTable
def build_container_routing_labels(prefix, strip_prefix=True): def build_container_routing_labels(prefix: str, strip_prefix=True):
router_key = "traefik.http.routers.{prefix}.rule".format(prefix=prefix) router_key = "traefik.http.routers.{prefix}.rule".format(prefix=prefix)
middleware_key = ( middleware_key = (
"traefik.http.middlewares.{prefix}-stripprefix.stripprefix.prefixes".format( "traefik.http.middlewares.{prefix}-stripprefix.stripprefix.prefixes".format(
@@ -42,21 +43,21 @@ def stop_container(docker_id):
container.kill() container.kill()
def start_foundry_container(table_name, prefix, version=12): def start_foundry_container(table: GameTable, version=12):
client = docker.from_env() client = docker.from_env()
image = "felddy/foundryvtt:{version}".format(version=version) image = "felddy/foundryvtt:{version}".format(version=version)
labels = build_container_routing_labels(prefix, False) labels = build_container_routing_labels(table.game_table_link, False)
volumes = { volumes = {
"/home/cow/Projects/dockertesting/server_data_mount/{prefix}".format( "/home/cow/Projects/dockertesting/server_data_mount/{prefix}".format(
prefix=prefix prefix=table.game_table_link
): {"bind": "/data", "mode": "rw"}, ): {"bind": "/data", "mode": "rw"},
"/home/cow/Projects/dockertesting/server_data_mount/foundry_cache": { "/home/cow/Projects/dockertesting/server_data_mount/foundry_cache": {
"bind": "/data/container_cache" "bind": "/data/container_cache"
}, },
} }
environment = [ environment = [
"FOUNDRY_ROUTE_PREFIX={prefix}".format(prefix=prefix) "FOUNDRY_ROUTE_PREFIX={prefix}".format(prefix=table.game_table_link)
] ]
container = client.containers.run( container = client.containers.run(

View File

@@ -84,7 +84,7 @@ def activate_table(table_id):
keys[0].reserve(table.game_table_id) keys[0].reserve(table.game_table_id)
table.active = True table.active = True
table.docker_id = container_managment.start_foundry_container( table.docker_id = container_managment.start_foundry_container(
table.game_table_name, table.game_table_link table
) )
app.logger.info(table.docker_id) app.logger.info(table.docker_id)
keys[0].commit(cursor) keys[0].commit(cursor)