Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Sep 28, 2024
2 parents 6a8b561 + afd780e commit 8c9ff0e
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 172 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Create a lab content directory like

And then request your page anywhere like this:

https://labs.usegalaxy.org.au/export/?content_root=https://raw.githubusercontent.com/my-username/my-labs-repo/my-lab/base.yml
https://labs.usegalaxy.org.au/?content_root=https://raw.githubusercontent.com/my-username/my-labs-repo/my-lab/base.yml

To get a webpage like
[this](https://labs.usegalaxy.org.au/export/?content_root=https://raw.githubusercontent.com/neoformit/galaxy-labs-engine/dev/app/labs/content/simple/main.yml).
[this](https://labs.usegalaxy.org.au/?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-labs-engine/dev/app/labs/content/simple/main.yml).
2 changes: 1 addition & 1 deletion ansible/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
vars_files:
- group_vars/VAULT
- group_vars/webservers.yml
- host_vars/labs.neoformit.com.yml
- host_vars/dev-labs.gvl.org.au.yml
roles:
- role: geerlingguy.docker
tags: init
Expand Down
5 changes: 4 additions & 1 deletion ansible/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
remote_user: ubuntu
become: true
vars_files:
- group_vars/secrets.yml
- group_vars/VAULT
- group_vars/webservers.yml
- host_vars/labs.usegalaxy.org.au.yml
roles:
- role: geerlingguy.docker
tags: init
- galaxy_labs_engine
22 changes: 11 additions & 11 deletions ansible/roles/galaxy_labs_engine/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- name: clone git repository for galaxy-labs-engine
ansible.builtin.git:
repo: https://github.com/neoformit/galaxy-labs-engine.git
branch: "{{ git_branch }}"
version: "{{ git_branch }}"
dest: "{{ project_root }}"
clone: yes
force: yes
Expand Down Expand Up @@ -50,14 +50,6 @@
loop: "{{ labs_engine.files }}"
tags: config

- name: Django create django_cache table with 'manage.py createcachetable'
shell: >
docker compose --profile prod run --rm labs-engine
python manage.py createcachetable
args:
chdir: "{{ config_root }}"
tags: django

- name: update media file ownership
file: dest={{ django_root }}/app/media owner=www-data group=www-data mode=u=rwX,g=rwX,o=rwX recurse=yes
tags:
Expand All @@ -75,6 +67,7 @@
tags:
- permissions
- update
ignore_errors: yes

- name: update sqlite3 database directory permissions
file:
Expand All @@ -86,6 +79,14 @@
- permissions
- update

- name: Django create django_cache table with 'manage.py createcachetable'
shell: >
docker compose --profile prod run --rm labs-engine
python manage.py createcachetable
args:
chdir: "{{ config_root }}"
tags: django

- name: Django run migrations
shell: >
docker compose --profile prod run --rm
Expand All @@ -100,12 +101,11 @@

- name: Django collect static files
shell: >
docker compose --profile prod run --rm
docker compose --profile prod run --rm --user root
labs-engine
python manage.py collectstatic --noinput
args:
chdir: "{{ config_root }}"
when: git.changed
tags: always

- name: Django ensure superuser login
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/galaxy_labs_engine/templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ server {

# Redirect all other traffic to HTTPS, but not the challenge
location / {
if ($host = labs.neoformit.com) {
if ($host = {{ inventory_hostname }}) {
return 301 https://$host$request_uri;
}
}
Expand Down
123 changes: 0 additions & 123 deletions app/app/settings.py

This file was deleted.

37 changes: 34 additions & 3 deletions app/app/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,40 @@
LOG_ROOT = ensure_dir(BASE_DIR / 'app/logs')
DEFAULT_EXPORTED_LAB_CONTENT_ROOT = (
f'http://{HOSTNAME}/static/labs/content/docs/base.yml')
GITHUB_CONTENT_ROOT_BASE_URL = (
"https://raw.githubusercontent.com/neoformit"
"/galaxy-labs-engine/dev/app/labs/content")

CODEX_REPO = 'galaxyproject/galaxy_codex'
CODEX_GITHUB_URL = f'https://github.com/{CODEX_REPO}'
LABS_ENGINE_GITHUB_REPO = 'usegalaxy-au/galaxy-labs-engine'
LABS_ENGINE_GITHUB_URL = f'https://github.com/{LABS_ENGINE_GITHUB_REPO}'
EXAMPLE_LABS = {
'FULL': {
'RAW_URL': (
f'https://raw.githubusercontent.com/{CODEX_REPO}/refs/heads/main'
'/communities/genome/lab/base.yml'),
'WEB_DIR_URL': (
f'{CODEX_GITHUB_URL}/blob/main'
'/communities/genome/lab'),
},
'DOCS': {
'RAW_URL': (
f'https://raw.githubusercontent.com/{LABS_ENGINE_GITHUB_REPO}/refs'
'/heads/main/app/labs/static/labs/content/docs/base.yml'),
'WEB_DIR_URL': (
f'{LABS_ENGINE_GITHUB_URL}/tree/dev/app/labs/static/labs/content'
'/docs'),
'WEB_DIR_ROOT': (
f'{LABS_ENGINE_GITHUB_URL}/blob/dev/app/labs/static/labs/content'
'/docs'),
},
'SIMPLE': {
'RAW_URL': (
f'https://raw.githubusercontent.com/{LABS_ENGINE_GITHUB_REPO}'
'/refs/heads/main/app/labs/static/labs/content/simple/base.yml'),
'WEB_DIR_URL': (
f'{LABS_ENGINE_GITHUB_URL}/blob/dev/app/labs/static/labs/content'
'/simple'),
},
}

# Hostnames
ALLOWED_HOSTS = [
Expand Down
3 changes: 0 additions & 3 deletions app/labs/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
def settings(request):
"""Include some settings variables."""
return {
'title': None, # prevents variable not found templating error
'HOSTNAME': app_settings.HOSTNAME,
"GITHUB_CONTENT_ROOT_BASE_URL":
app_settings.GITHUB_CONTENT_ROOT_BASE_URL,
}
11 changes: 4 additions & 7 deletions app/labs/lab_export.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Exported landing pages to be requested by external Galaxy servers.
Example with local YAML:
http://127.0.0.1:8000/landing/export?content_root=http://127.0.0.1:8000/static/labs/content/genome/main.yml
http://127.0.0.1:8000/?content_root=http://127.0.0.1:8000/static/labs/content/simple/base.yml
Example URL with remote YAML:
http://127.0.0.1:8000/landing/export?content_root=https://raw.githubusercontent.com/neoformit/galaxy-labs-engine/dev/app/labs/content/... base.yml # noqa
http://127.0.0.1:8000/?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-labs-engine/blob/main/app/labs/content/simple/base.yml
"""

Expand Down Expand Up @@ -140,12 +140,9 @@ def looks_like_a_webpage(response):

def _validate_url(self, url, expected_type):
"""Validate URL to prevent circular request."""
if (
'/lab/export' in url
and url.split('/')[1, 2] == ['lab', 'export']
):
if url.strip('/').split('/')[-1] == settings.HOSTNAME:
raise LabBuildError(
"URL cannot contain '/lab/export'.",
"URL cannot match the root URL of this server",
url=url,
source=expected_type,
)
Expand Down
2 changes: 1 addition & 1 deletion app/labs/static/labs/content/docs/base.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Default spec for an exported lab landing page

# You can test with: /lab/export?content_root=https://raw.githubusercontent.com/neoformit/galaxy-labs-engine/dev/app/labs/content/docs/base.yml
# You can test with: /?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-labs-engine/dev/app/labs/content/docs/base.yml

site_name: Antarctica
lab_name: Galaxy Lab Pages
Expand Down
Loading

0 comments on commit 8c9ff0e

Please sign in to comment.