diff --git a/docker-compose.yml b/docker-compose.yml index 7dcbcc3..fe83150 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,6 @@ include: - mariadb/compose.yml - caddy/compose.yml -volumes: - gitea: - networks: gitea-net: external: false diff --git a/gitea/compose.yml b/gitea/compose.yml index 28bcd97..e7aa005 100644 --- a/gitea/compose.yml +++ b/gitea/compose.yml @@ -21,21 +21,6 @@ services: db: condition: service_healthy -volumes: - gitea: - caddy_data: - caddy_config: - - networks: gitea-net: external: false - seafile-net: - external: false - caddy: - external: false - driver: bridge - auth: - external: true - postgres: - external: false diff --git a/init.py b/init.py index a1c50a3..0e548bf 100755 --- a/init.py +++ b/init.py @@ -74,10 +74,15 @@ def sql_add_user(username, password, *databases): print(f"CREATE DATABASE {db};") print(f"GRANT ALL PRIVILEGES ON {db} TO {username};") -def seafile_init(): - print("setting up seafile...") +def parse_env(service): + """ + parse_env returns a dictionary of env vars parsed from the base file - f = open("seafile/env") + :service: is a string of the service name to parse, must match folder name + """ + print(f"setting up {service}...") + + f = open(f"{service}/env") c = dict() for line in f: # skip comments @@ -96,14 +101,33 @@ def seafile_init(): c[key] = val - print(c) + return c +def gen_env(kv): + """ + gen_env takes in a dictionary and writes out each pair into an env file + + :kv: is a dictionary of strings + """ + for key, value in kv.items(): + print(f"{key}=\"{value}\"") + +def mariadb_init(): + c = parse_env("mariadb") + password = c["MYSQL_ROOT_PASSWORD"] + + sql_init(password) + gen_env(c) + +def seafile_init(): + c = parse_env("seafile") username = c["SEAFILE_MYSQL_DB_USER"] password = c["SEAFILE_MYSQL_DB_PASSWORD"] dbs = ["ccnet_db", "seafile_db", "seahub_db"] sql_add_user(username, password, *dbs) -seafile_init() +# seafile_init() +mariadb_init() # def get_env(): # print(os.environ['PWD']) diff --git a/mariadb/compose.yml b/mariadb/compose.yml index 3fd3d72..e09818b 100644 --- a/mariadb/compose.yml +++ b/mariadb/compose.yml @@ -1,25 +1,8 @@ services: - caddy: - image: caddy - restart: unless-stopped - ports: - - "80:80" - - "443:443" - - "443:443/udp" - networks: - auth - caddy - volumes: - - config/Caddyfile:/etc/caddy/Caddyfile - - website/public:/srv/keegan - - fish:/srv/fish - - volumes/caddy/data:/data - - volumes/caddy/config:/config - mariadb: image: mariadb:10.11 container_name: mariadb - env-file: "priv/env" + env-file: ".env" volumes: - ./volumes/mariadb/db:/var/lib/mysql - ./priv/init.sql:/script/init.sql @@ -39,96 +22,3 @@ services: start_period: 30s timeout: 5s retries: 10 - - memcached: - image: memcached:1.6.29 - container_name: seafile-memcached - entrypoint: memcached -m 256 - networks: - - seafile-net - - notification-server: - image: seafileltd/notification-server:12.0-latest - container_name: seafile-notification-server - restart: unless-stopped - volumes: - - volumes/seafile/noti:/shared - environment: - - SEAFILE_MYSQL_DB_HOST=${SEAFILE_MYSQL_DB_HOST:-db} - - SEAFILE_MYSQL_DB_USER=${SEAFILE_MYSQL_DB_USER:-seafile} - - SEAFILE_MYSQL_DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD:?Variable is not set or empty} - - SEAFILE_MYSQL_DB_CCNET_DB_NAME=${SEAFILE_MYSQL_DB_CCNET_DB_NAME:-ccnet_db} - - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=${SEAFILE_MYSQL_DB_SEAFILE_DB_NAME:-seafile_db} - - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY:?Variable is not set or empty} - - SEAFILE_LOG_TO_STDOUT=${SEAFILE_LOG_TO_STDOUT:-false} - - NOTIFICATION_SERVER_LOG_LEVEL=${NOTIFICATION_SERVER_LOG_LEVEL:-info} - labels: - caddy: ${SEAFILE_SERVER_PROTOCOL:-http}://${SEAFILE_SERVER_HOSTNAME:?Variable is not set or empty} - caddy.@ws.0_header: "Connection *Upgrade*" - caddy.@ws.1_header: "Upgrade websocket" - caddy.0_reverse_proxy: "@ws {{upstreams 8083}}" - caddy.1_handle_path: "/notification*" - caddy.1_handle_path.0_rewrite: "* {uri}" - caddy.1_handle_path.1_reverse_proxy: "{{upstreams 8083}}" - depends_on: - db: - condition: service_healthy - networks: - - seafile-net - - seafile: - image: seafileltd/seafile-mc:12.0-latest - container_name: seafile - volumes: - - /opt/seafile-mysql:/shared - env-file: "priv/env" - environment: - - JWT_PRIVATE_KEY=${SEAFILE_JWT_PRIVATE_KEY} - depends_on: - db: - condition: service_healthy - memcached: - condition: service_started - networks: - - seafile-net - - caddy - - gitea: - image: gitea/gitea:latest-rootless - restart: unless-stopped - env-file: "priv/env" - restart: always - networks: - - gitea - - caddy - volumes: - - ./volumes/gitea/data:/var/lib/gitea - - ./volumes/gitea/config:/etc/gitea - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - # allows ssh pushing via locally stored keys - - /home/git/.ssh:/data/git/.ssh - ports: - - "127.0.0.1:2222:22" - depends_on: - db: - condition: service_healthy - -volumes: - gitea: - caddy_data: - caddy_config: - - -networks: - gitea-net: - external: false - seafile-net: - external: false - caddy: - external: false - driver: bridge - auth: - external: true - postgres: - external: false