-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Databrowser api #64
Closed
Closed
Databrowser api #64
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
652ab20
Update checkout workflow action to v4
antarcticrainforest de33984
Add instructions for adding the databrowser-api
antarcticrainforest 6b0e5fb
Switch to docker-compose
antarcticrainforest f35c332
Use <project_name>-<step> as compose project name.
antarcticrainforest 713cf25
Add execstop command for systemd units.
antarcticrainforest b7ad172
Use rich logger
antarcticrainforest 2daa312
Only print relevant ansible variables.
antarcticrainforest 32b54c7
Fix linting issues.
antarcticrainforest 668bf04
update tui
antarcticrainforest 2d2d5bc
Update docs.
antarcticrainforest c09c6cb
Update README
antarcticrainforest 6a24614
Fix linting issues.
antarcticrainforest 318d946
Fix linting issues.
antarcticrainforest 0667450
update tui
antarcticrainforest a309a25
Merge branch 'main' of github.com:FREVA-CLINT/freva-deployment into d…
antarcticrainforest 61e8635
delete setup.py
antarcticrainforest d1f5961
Merge branch 'main' of github.com:FREVA-CLINT/freva-deployment into d…
antarcticrainforest 9be709f
Merge branch 'main' of github.com:FREVA-CLINT/freva-deployment into d…
antarcticrainforest 3365a87
Rename extras
antarcticrainforest 988ebff
Fix broken merge from main
antarcticrainforest c842426
Fix linting issues.
antarcticrainforest ad3eec0
Fix linting issues
antarcticrainforest d44eeb0
Merge branch 'main' of github.com:FREVA-CLINT/freva-deployment into d…
antarcticrainforest 8301fb9
Fix isort issues.
antarcticrainforest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
assets/share/freva/deployment/playbooks/databrowser-server-compose-template.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: '3' | ||
services: | ||
{{solr_name}}: | ||
image: solr:latest | ||
container_name: {{solr_name}} | ||
hostname: {{solr_name}} | ||
networks: | ||
- {{databrowser_name}} | ||
environment: | ||
- CORE=files | ||
- NUM_BACKUPS=7 | ||
- SOLR_HEAP={{databrowser_solr_mem}} | ||
volumes: | ||
{% for volume in solr_volumes %} | ||
- {{volume}} | ||
{% endfor %} | ||
tty: true | ||
ports: | ||
- {{databrowser_solr_port}}:8983 | ||
|
||
{{mongo_name}}: | ||
image: mongo:latest | ||
container_name: {{mongo_name}} | ||
hostname: {{mongo_name}} | ||
networks: | ||
- {{databrowser_name}} | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=mongo | ||
- MONGO_INITDB_ROOT_PASSWORD={{ root_passwd}} | ||
- MONGO_INITDB_DATABASE=search_stats | ||
volumes: | ||
{% for volume in mongo_volumes %} | ||
- {{volume}} | ||
{% endfor %} | ||
ports: | ||
- 27017:27017 | ||
tty: true | ||
|
||
{{databrowser_name}}: | ||
image: ghcr.io/freva-clint/databrowserapi:latest | ||
hostname: {{databrowser_name}} | ||
networks: | ||
- {{databrowser_name}} | ||
environment: | ||
- SOLR_CORE=files | ||
- SOLR_HOST={{solr_name}}:8983 | ||
- MONGO_HOST={{mongo_name}}:27017 | ||
- MONGO_PASSWORD={{ root_passwd}} | ||
- MONGO_DB=search_stats | ||
- MONGO_USER=mongo | ||
ports: | ||
- {{databrowser_port}}:8080 | ||
container_name: {{databrowser_name}} | ||
depends_on: | ||
- {{solr_name}} | ||
- {{mongo_name}} | ||
tty: true | ||
|
||
networks: | ||
{{databrowser_name}}: | ||
driver: bridge |
151 changes: 151 additions & 0 deletions
151
assets/share/freva/deployment/playbooks/databrowser-server-playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
--- | ||
- hosts: databrowser | ||
|
||
vars: | ||
ansible_python_interpreter: "{{ databrowser_ansible_python_interpreter }}" | ||
databrowser_name: "{{project_name}}-databrowser" | ||
compose_file: /opt/freva/compose_services/{{databrowser_name}}-compose.yml | ||
solr_name: "{{project_name}}-solr" | ||
mongo_name: "{{project_name}}-mongo" | ||
solr_volumes: | ||
- /opt/freva/{{project_name}}/solr_service:/var/solr/data:z | ||
- /opt/freva/freva-service-config/solr/managed-schema.xml:/opt/solr/managed-schema.xml:z | ||
- /opt/freva/freva-service-config/solr/create_cores.sh:/docker-entrypoint-initdb.d/create_cores.sh:z | ||
- /opt/freva/freva-service-config/solr/synonyms.txt:/opt/solr/synonyms.txt:z | ||
- /opt/freva/freva-service-config/solr/daily_backup.sh:/usr/local/bin/daily_backup:z | ||
mongo_volumes: | ||
- /opt/freva/{{project_name}}/databrowser/stats:/data/db:z | ||
ansible_become_user: "{{ databrowser_ansible_become_user | default('root') }}" | ||
use_become: "{{ databrowser_ansible_become_user is defined and databrowser_ansible_become_user != '' }}" | ||
tasks: | ||
- name: Copying docker/podman wrapper script | ||
copy: | ||
src: "{{ asset_dir }}/scripts/docker-or-podman" | ||
dest: /tmp/docker-or-podman | ||
mode: "0775" | ||
- name: Registering systemctl path | ||
stat: | ||
path: /usr/bin/systemctl | ||
register: systemctl | ||
- name: Registering anacron path | ||
stat: | ||
path: /etc/cron.daily | ||
register: cron | ||
- name: Stopping services and deleting existing containers | ||
become: "{{use_become}}" | ||
shell: > | ||
systemctl stop {{solr_name}} {{mongo_name}} {{databrowser_name}}; | ||
systemctl disable {{solr_name}} {{mongo_name}} {{databrowser_name}}; | ||
systemctl reset-failed; | ||
/tmp/docker-or-podman rm {{solr_name}} {{mongo_name}} {{databrowser_name}}; | ||
/tmp/docker-or-podman rmi -f {{solr_name}} {{mongo_name}} {{databrowser_name}}; | ||
/tmp/docker-or-podman rmi -f solr mongo ghcr.io/freva-clint/databrowserapi; | ||
exit 0 | ||
ignore_errors: true | ||
- pause: seconds=5 | ||
- name: Deleting old systemd structure | ||
file: | ||
state: absent | ||
path: "/etc/systemd/system/{{item}}.service" | ||
force: true | ||
with_items: | ||
- "{{solr_name}}" | ||
- "{{mongo_name}}" | ||
- "{{databrowser_name}}" | ||
become: "{{use_become}}" | ||
when: systemctl.stat.exists == true | ||
- name: Deleting config file | ||
file: | ||
state: absent | ||
force: true | ||
path: /opt/freva/freva-service-config/ | ||
become: "{{use_become}}" | ||
- name: Cleaning existing directory structure | ||
file: | ||
path: "{item}" | ||
state: absent | ||
with_items: | ||
- "/opt/freva/{{ project_name }}/solr_service" | ||
- "/opt/freva/{{ project_name }}/databrowser" | ||
when: databrowser_wipe == true | ||
become: "{{use_become}}" | ||
- name: Creating solr directory structure | ||
file: | ||
path: /opt/freva/{{ project_name }}/solr_service | ||
state: directory | ||
owner: 8983 | ||
group: 8983 | ||
recurse: true | ||
become: "{{use_become}}" | ||
- name: Creating compose directory structure | ||
file: | ||
path: /opt/freva/compose_services | ||
state: directory | ||
recurse: true | ||
become: "{{use_become}}" | ||
- name: Creating directory structure | ||
file: | ||
path: /opt/freva/{{ project_name }}/databrowser | ||
state: directory | ||
recurse: true | ||
become: "{{use_become}}" | ||
- name: Getting additional configurations | ||
git: | ||
repo: https://github.com/FREVA-CLINT/freva-service-config.git | ||
dest: /opt/freva/freva-service-config | ||
update: true | ||
become: "{{use_become}}" | ||
- name: Copy systemd files | ||
copy: | ||
src: "{{ asset_dir }}/scripts/create_systemd.py" | ||
dest: /tmp/create_systemd.py | ||
mode: "0755" | ||
become: "{{use_become}}" | ||
- name: Pulling container | ||
shell: | ||
cmd: /tmp/docker-or-podman pull {{item}} | ||
become: "{{use_become}}" | ||
with_items: | ||
- "docker.io/solr:latest" | ||
- "docker.io/mongo:latest" | ||
- "ghcr.io/freva-clint/databrowserapi:latest" | ||
- name: Copy cron create script to target machine | ||
copy: src="{{ asset_dir }}/scripts/create_cron.sh" dest=/tmp/solr_service/ | ||
become: "{{use_become}}" | ||
- name: Creating compose file | ||
become: "{{use_become}}" | ||
template: | ||
src: "{{ asset_dir }}/playbooks/databrowser-server-compose-template.yml" | ||
dest: "{{compose_file}}" | ||
- name: Creating systemd services | ||
shell: | | ||
/tmp/create_systemd.py {{databrowser_name}} compose --enable --project-name {{databrowser_name}} -f {{compose_file}} up --remove-orphans | ||
when: systemctl.stat.exists == true | ||
become: "{{use_become}}" | ||
- pause: seconds=3 | ||
- name: Creating cron jobs | ||
shell: > | ||
sh /tmp/solr_service/create_cron.sh "{{ solr_name }}" "{{databrowser_email}}" | ||
when: systemctl.stat.exists == true | ||
become: "{{use_become}}" | ||
- name: Deleting tmporary files | ||
file: | ||
path: "{{item}}" | ||
state: absent | ||
with_items: | ||
- /tmp/docker-or-podman | ||
- /tmp/create_systemd.py | ||
- /tmp/solr_service | ||
become: "{{use_become}}" | ||
- hosts: web | ||
vars: | ||
use_become: "{{ web_ansible_become_user is defined and web_ansible_become_user != '' }}" | ||
tasks: | ||
- name: Registering systemctl path | ||
stat: | ||
path: /usr/bin/systemctl | ||
register: systemctl | ||
- name: Restarting web container | ||
shell: systemctl restart {{web_name}}; echo 0 | ||
become: "{{use_become}}" | ||
when: systemctl.stat.exists == true |
29 changes: 29 additions & 0 deletions
29
assets/share/freva/deployment/playbooks/db-server-compose-template.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '3' | ||
services: | ||
{{db_name}}: | ||
image: mariadb:latest | ||
hostname: {{db_name}} | ||
networks: | ||
- {{db_name}} | ||
environment: | ||
- ROOT_PW={{ root_passwd }} | ||
- HOST={{ db_host }} | ||
- NUM_BACKUPS=7 | ||
- PROJECT={{ project_name }} | ||
- MYSQL_USER={{db_user}} | ||
- MYSQL_PASSWORD={{db_passwd}} | ||
- MYSQL_DATABASE={{db}} | ||
- MYSQL_ROOT_PASSWORD={{ root_passwd }} | ||
- BACKUP_DIR=/var/lib/mysql/backup | ||
volumes: | ||
{% for volume in db_volumes %} | ||
- {{volume}} | ||
{% endfor %} | ||
container_name: {{db_name}} | ||
tty: true | ||
ports: | ||
- {{db_port}}:3306 | ||
|
||
networks: | ||
{{db_name}}: | ||
driver: bridge |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
docker-compose
. Hencedocker-compose
(orpodman-compose
) has to be