Page MenuHomeDevCentral

D2465.id6221.diff
No OneTemporary

D2465.id6221.diff

diff --git a/PORTS b/PORTS
--- a/PORTS
+++ b/PORTS
@@ -38,4 +38,6 @@
41080 ACME DNS server HTTP
42080 Jenkins HTTP - CI
43080 Hauk
+ 44080 Hound
+ # 45080 should be reserved for OpenGrok to compare with Hound
50000 Jenkins master's port for JNLP-based Jenkins agents - CD
diff --git a/pillar/paas/docker.sls b/pillar/paas/docker.sls
--- a/pillar/paas/docker.sls
+++ b/pillar/paas/docker.sls
@@ -51,6 +51,7 @@
- nasqueron/etherpad:production
- nasqueron/notifications
- nasqueron/phabricator
+ - ghcr.io/hound-search/hound
# Continuous deployment jobs
- jenkins/jenkins
@@ -281,6 +282,12 @@
# Infrastructure and development services
+ hound:
+ hound:
+ app_port: 44080
+ host: code.nasqueron.org
+ github_account: nasqueron
+
notifications:
notifications:
host: notifications.nasqueron.org
diff --git a/roles/paas-docker/containers/files/hound/generate-config.py b/roles/paas-docker/containers/files/hound/generate-config.py
new file mode 100755
--- /dev/null
+++ b/roles/paas-docker/containers/files/hound/generate-config.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+
+
+import json
+import sys
+
+
+POLL_TIME = 3600000
+
+
+# -------------------------------------------------------------
+# Configuration methods
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def generate_config(account, repositories):
+ repos = [get_repo_config(account, repo) for repo in repositories]
+
+ return {
+ "max-concurrent-indexers": 2,
+ "dbpath": "data",
+ "title": f"{account} code search".title(),
+ "health-check-uri": "/healthz",
+ "repos": dict(repos)
+ }
+
+
+def get_repo_config(account, repo):
+ return repo[0], {
+ "url": f"https://www.github.com/{account}/{repo[0]}.git",
+ "vcs-config": {
+ "ref": repo[1],
+ },
+ "ms-between-poll": POLL_TIME,
+ }
+
+
+# -------------------------------------------------------------
+# Application entry point
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def run(account):
+ repos = [line.strip().split(",") for line in sys.stdin]
+
+ config = generate_config(account, repos)
+ print(json.dumps(config))
+
+
+if __name__ == "__main__":
+ try:
+ account = sys.argv[1]
+ except IndexError:
+ print("Usage:", sys.argv[0], "<GitHub org account>", file=sys.stderr)
+ sys.exit(2)
+
+ run(account)
diff --git a/roles/paas-docker/containers/hound.sls b/roles/paas-docker/containers/hound.sls
new file mode 100644
--- /dev/null
+++ b/roles/paas-docker/containers/hound.sls
@@ -0,0 +1,75 @@
+# -------------------------------------------------------------
+# Salt — Provision Docker engine
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% set has_selinux = salt['grains.get']('selinux:enabled', False) %}
+{% set containers = pillar['docker_containers'][grains['id']] %}
+
+
+# -------------------------------------------------------------
+# Configuration provider
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/usr/local/bin/hound-generate-config:
+ file.managed:
+ - source: salt://roles/paas-docker/containers/files/hound/generate-config.py
+ - mode: 755
+
+
+{% for instance, container in containers['hound'].items() %}
+
+# -------------------------------------------------------------
+# Home directory
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/srv/hound/{{ instance }}:
+ file.directory:
+ - makedirs: True
+
+{% if has_selinux %}
+selinux_context_{{ instance }}_data:
+ selinux.fcontext_policy_present:
+ - name: /srv/hound/{{ instance }}
+ - sel_type: container_file_t
+
+selinux_context_{{ instance }}_data_applied:
+ selinux.fcontext_policy_applied:
+ - name: /srv/hound/{{ instance }}
+{% endif %}
+
+# -------------------------------------------------------------
+# Configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% set repos_path = "/srv/hound/" + instance + "/repos.txt" %}
+{% set config_path = "/srv/hound/" + instance + "/config.json" %}
+
+hound_{{ instance }}_repositories:
+ cmd.run:
+ - name: docker run --rm nasqueron/devtools github/list-repositories.py {{ container['github_account'] }} -b > {{ repos_path }}
+ - creates: {{ repos_path }}
+
+hound_{{ instance }}_config:
+ cmd.run:
+ - name: hound-generate-config {{ container['github_account'] }} < {{ repos_path }} > {{ config_path }}
+ - creates: {{ config_path }}
+
+# -------------------------------------------------------------
+# Container
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{{ instance }}:
+ docker_container.running:
+ - detach: True
+ - interactive: True
+ - image: ghcr.io/hound-search/hound
+ - binds: /srv/hound/{{ instance }}:/data
+ - ports:
+ - 6080
+ - port_bindings:
+ - {{ container['app_port'] }}:6080
+
+{% endfor %}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 14:50 (20 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2271268
Default Alt Text
D2465.id6221.diff (5 KB)

Event Timeline