From 1e5b27906e5ff562e4ed8d9c862e729693c10ab2 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sun, 25 Oct 2026 18:59:16 +0100 Subject: [PATCH] freecad-bot: Initial config Co-Authored-By: Claude Opus 5.5 --- services/freecad-bot/config/config.yaml | 44 +++++++ services/freecad-bot/config/proxy.conf | 15 +++ services/freecad-bot/stack.yml | 75 ++++++++++++ services/freecad-bot/tasks/config.yml | 16 +++ services/freecad-bot/vars/main.yml | 8 ++ vars/services.yml | 150 ++++++++++++++++++++++++ 6 files changed, 308 insertions(+) create mode 100644 services/freecad-bot/config/config.yaml create mode 100644 services/freecad-bot/config/proxy.conf create mode 100644 services/freecad-bot/stack.yml create mode 100644 services/freecad-bot/tasks/config.yml create mode 100644 services/freecad-bot/vars/main.yml diff --git a/services/freecad-bot/config/config.yaml b/services/freecad-bot/config/config.yaml new file mode 100644 index 0000000..c0d7ce6 --- /dev/null +++ b/services/freecad-bot/config/config.yaml @@ -0,0 +1,44 @@ +discord: + token: {{ freecad_bot_discord_token }} + command_prefix: "!" + +channels: + {{ freecad_bot_channels | to_nice_yaml(indent=2) | indent(2) }} + +{% if freecad_bot_mention_forwards is defined %} +mention_forwards: + {{ freecad_bot_mention_forwards | to_nice_yaml(indent=2) | indent(2) }} +{% endif %} + +commands: + allowed_role_ids: {{ freecad_bot_allowed_role_ids }} + throttle_seconds: {{ freecad_bot_throttle_seconds }} + +github: + webhook_secret: {{ freecad_bot_github_webhook_secret }} + api_token: {{ freecad_bot_github_api_token }} + +server: + host: "0.0.0.0" + port: 8080 + public_url: "https://{{ freecad_bot_domain }}" + api_token: {{ freecad_bot_server_api_token }} + +ai: + provider: gemini + api_key: {{ freecad_bot_ai_api_key }} + model: {{ freecad_bot_ai_model }} + max_output_tokens: 8192 + +bot: + flush_interval_minutes: 5 + log_dir: /data/logs + db_path: /data/bot.db + +s3: + endpoint_url: "{{ freecad_bot_s3_endpoint_url }}" + bucket: "{{ freecad_bot_s3_bucket }}" + access_key: "{{ freecad_bot_s3_access_key }}" + secret_key: "{{ freecad_bot_s3_secret_key }}" + region: "us-east-1" + public_base_url: "{{ freecad_bot_s3_public_url }}" diff --git a/services/freecad-bot/config/proxy.conf b/services/freecad-bot/config/proxy.conf new file mode 100644 index 0000000..32cf825 --- /dev/null +++ b/services/freecad-bot/config/proxy.conf @@ -0,0 +1,15 @@ +server { + listen 80; + + location /media/ { + proxy_pass http://cdn/; + } + + location / { + proxy_pass http://bot:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/services/freecad-bot/stack.yml b/services/freecad-bot/stack.yml new file mode 100644 index 0000000..1dc6537 --- /dev/null +++ b/services/freecad-bot/stack.yml @@ -0,0 +1,75 @@ +version: "{{ compose_version }}" + +services: + bot: + image: registry.kadet.net/freecad/discord-bot:latest + environment: + BOT_LOG_DIR: /data/logs + configs: + - source: config_{{ bot_config.checksum }} + target: /app/config.yaml + mode: 0444 + volumes: + - bot-data:/data + networks: + - "{{ ingress_network }}" + - default + secrets: + - source: dockerregistryauth + target: /run/secrets/dockerregistryauth + deploy: + mode: replicated + replicas: 1 + + proxy: + image: nginx:alpine + networks: + - "{{ ingress_network }}" + - default + configs: + - source: proxy_conf_{{ proxy_conf.checksum }} + target: /etc/nginx/conf.d/default.conf + mode: 0444 + deploy: + mode: replicated + replicas: 1 + labels: + - traefik.enable=true + - traefik.http.routers.{{ service }}.rule=Host(`{{ freecad_bot_domain }}`) + - traefik.http.routers.{{ service }}.tls=true + - traefik.http.routers.{{ service }}.tls.certresolver=lets-encrypt + - traefik.http.services.{{ service }}.loadbalancer.server.port=80 + + cdn: + image: nginxinc/nginx-s3-gateway:latest-njs-oss + restart: unless-stopped + environment: + S3_BUCKET_NAME: "{{ freecad_bot_s3_bucket }}" + S3_SERVER: "{{ freecad_bot_s3_endpoint_url | urlsplit('hostname') }}" + S3_SERVER_PORT: "{{ freecad_bot_s3_endpoint_url | urlsplit('port') or ('443' if (freecad_bot_s3_endpoint_url | urlsplit('scheme')) == 'https' else '80') }}" + S3_SERVER_PROTO: "{{ freecad_bot_s3_endpoint_url | urlsplit('scheme') }}" + S3_REGION: eu-central-003 + S3_STYLE: path + AWS_SIGS_VERSION: "4" + AWS_ACCESS_KEY_ID: "{{ freecad_bot_s3_access_key }}" + AWS_SECRET_ACCESS_KEY: "{{ freecad_bot_s3_secret_key }}" + ALLOW_DIRECTORY_LIST: "false" + PROXY_CACHE_MAX_SIZE: 10g + PROXY_CACHE_INACTIVE: 365d + PROXY_CACHE_VALID_OK: "365d" + PROXY_CACHE_VALID_NOTFOUND: "0" + PROXY_CACHE_VALID_FORBIDDEN: "0" + +secrets: + dockerregistryauth: + name: dockerregistryauth + external: true + +configs: + config_{{ bot_config.checksum }}: + file: ./config/config.yaml + proxy_conf_{{ proxy_conf.checksum }}: + file: ./config/proxy.conf + +volumes: + bot-data: {} diff --git a/services/freecad-bot/tasks/config.yml b/services/freecad-bot/tasks/config.yml new file mode 100644 index 0000000..c9e969c --- /dev/null +++ b/services/freecad-bot/tasks/config.yml @@ -0,0 +1,16 @@ +--- +- name: 'Copy config.yaml for "{{ service }}"' + template: + src: "{{ service_path }}/config/config.yaml" + dest: "{{ remote_service_path }}/config/config.yaml" + register: bot_config + tags: + - config + +- name: 'Copy proxy.conf for "{{ service }}"' + template: + src: "{{ service_path }}/config/proxy.conf" + dest: "{{ remote_service_path }}/config/proxy.conf" + register: proxy_conf + tags: + - config diff --git a/services/freecad-bot/vars/main.yml b/services/freecad-bot/vars/main.yml new file mode 100644 index 0000000..e45a6e9 --- /dev/null +++ b/services/freecad-bot/vars/main.yml @@ -0,0 +1,8 @@ +--- +freecad_bot_domain: wg.freecad.org +freecad_bot_ai_model: gemini-flash-latest +freecad_bot_throttle_seconds: 60 + +freecad_bot_s3_endpoint_url: "http://minio:9000" +freecad_bot_s3_bucket: freecad-bot +freecad_bot_s3_public_url: "https://{{ freecad_bot_domain }}/media" diff --git a/vars/services.yml b/vars/services.yml index 0797a1f..48c1f0b 100644 --- a/vars/services.yml +++ b/vars/services.yml @@ -341,5 +341,155 @@ service_config: 30653966353632333164306262363031626137373761636166663533366231336637383334316637 3463613562343766613666666264646433353731313334336130 + freecad-bot: + freecad_bot_s3_endpoint_url: https://s3.eu-central-003.backblazeb2.com + freecad_bot_s3_bucket: freecad-media + freecad_bot_s3_secret_key: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 33663839636563626262613031326137383033393165303638396631353832323836326437616563 + 3836613330653466653531666362646236303965303466350a373831303638343233663662393833 + 33336163623835383963663565373533343732636163386433326238313762373138303665653161 + 6139326537346531660a653864356339323861633563323463313633383032663630643866303661 + 39303530616631643531333433653632653235303433336266653266373635663264 + freecad_bot_s3_access_key: 003d67a35e3918f0000000006 + + freecad_bot_discord_token: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 66646262373534316338646532386564316136346361313439336664383565633161666237623239 + 6262633433393030356161326364383831306165626564620a383930333462303937343836386364 + 30326130626233363362383561373930633332623331663234396534343064653163303333666638 + 6534333364343062330a346461313364373739393831316536663161393631313330376263666665 + 37663933336264396335613335633865336439633830326136356465653265336362363165633332 + 31353939663439623230613434373434623831363232626138333739393030643336353465666465 + 31353230346232306533386663343739366161363561366537323466643665663931306161616435 + 33373262316137373562 + freecad_bot_github_webhook_secret: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 38363639326538653562313562643932363435336631663562336663643239333766313461316231 + 3733326332343832313566636464326662313634646533640a383239623833656362626437633539 + 37316561333738343565323433633130373038363435316365653039653161653633373565303739 + 3862613964626339370a653138343135366432653237666532323561306662366638303365353334 + 36306235626136643465306265623135366364373137663634373562363165633130613634643433 + 6536663234343834323038343632336236346430353763366437 + freecad_bot_github_api_token: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 37306637316535316665373363356331613234633465343762613266356531376230303531626163 + 6565393230393031323536643132323834343131303937330a343635633463356135333537626639 + 61313961363338333133613338363134663830303434643230666137393132333736326566623361 + 3636363533333134630a343239623965333136326339646434366234643735303632383963656165 + 62646664323134373266323966663932363033636432343234323264633662363633376330353139 + 3636383239626363333436356131373862336537646462356134 + freecad_bot_ai_api_key: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 66656134643833656535363561333663616162323430383261613062313930623134643965333164 + 3039363165363235373236396365356636333737383563320a663133636138366237366339373939 + 31323266343037346336613931663164343266343032613633303463356166633130333337313464 + 3437353563386466640a346134343137366366343864363532376633303038323564363230353939 + 35336265373734613437646131326239346161643861643232306662373464333064633933366439 + 6161346661643761653934303437623064666530313566323435 + freecad_bot_server_api_token: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 33393836373536366632643432636264363030343730356339326331383261313864306335313863 + 3364363832636237623061663931653863323938633132660a306138613939646661313036386264 + 65666661646666623636306264653535373830653639333839303931666461333333353537663033 + 3932333335333339390a353763313635333639323838303333373030656162343064383932656238 + 31303739613038643937343731376630663739616236343432313933633535376661333632326331 + 3463303037393838363062363964303632336261343436306536 + freecad_bot_channels: + - forum_channel_id: 1163884496031064134 # ux-reviews + group_role_id: 1163882419284361306 # Design Working Group + notify_on_create: true + alert_disable_tags: + - 1499434107229179924 + - 1384666110191997051 + - 1384666248994095226 + - 1497685898161033226 + - 1524890424609865929 + trigger_label: "Requires: UI/UX review" + github_comment: > + This {type} was marked for UI/UX review. If you'd like to talk it over with the + group, join the discussion at {discord_url}, or ping `@FreeCAD/design-working-group` + here. The discussion is recorded and will be available at {log_url}. + type_effects: + issue: + tag: 1524890424609865929 # FILL ME: Discord ForumTag ID for issue threads + pr: + tag: 1524890475461611744 # FILL ME: Discord ForumTag ID for PR threads + label_effects: + "Requires: UI/UX review": + tag: 1371528009978351667 + "Approved: UI/UX": + tag: 1371529173797175428 + prefix: "✔" + "Requested changes: UI/UX": + tag: 1371529341518745600 + prefix: "✎" + "Status: Needs feedback": &hold + tag: 1499434107229179924 + prefix: "⏸" + "✋ On hold": *hold + state_effects: + issue_resolved: + tag: 1384666110191997051 + prefix: "✔" + close: true + issue_not_planned: + tag: 1497685898161033226 + prefix: "✘" + close: true + pr_merged: + tag: 1384666248994095226 + prefix: "✔" + close: true + pr_closed: + tag: 1497685898161033226 + prefix: "✘" + close: true + pr_draft: *hold + github_repositories: + - FreeCAD/FreeCAD + alerts: + - days: 30 + message_type: message + alert_type: from_start + message: "The discussion was not resolved within a month time." + - days: 60 + message_type: mention + alert_type: from_start + message: "The discussion was not resolved within two months from the start." + - days: 10 + message_type: message + alert_type: from_last_message + message: "No discussion happened since {days} day(s). If it was resolved, please respond in the {url}." + - days: 20 + message_type: mention + alert_type: from_last_message + message: "No discussion happened since {days} day(s). If it was resolved, please respond in the {url}." + freecad_bot_allowed_role_ids: + - 1163882419284361306 + - 1347281912183394314 + - 1285656872287866994 + freecad_bot_mention_forwards: + - github_team: "FreeCAD/code-quality-working-group" + discord_channel_id: 1354091047185154058 + discord_role_id: 1347281912183394314 + github_repositories: + - FreeCAD/FreeCAD + - github_team: "FreeCAD/cad-working-group" + discord_channel_id: 1277336851044106360 + discord_role_id: 1285656872287866994 + github_repositories: + - FreeCAD/FreeCAD + - github_team: "FreeCAD/design-working-group" + discord_channel_id: 1162044910535450665 + discord_role_id: 1163882419284361306 + github_repositories: + - FreeCAD/FreeCAD + - github_team: "FreeCAD/packaging-team" + discord_channel_id: 1503510285661634591 + discord_role_id: 1505556341526233148 + github_repositories: + - FreeCAD/FreeCAD + www_data_users: - vagrant