-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
183 lines (166 loc) · 7.84 KB
/
Taskfile.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Taskfile
# ========
#
# Convenient things to run. Depends on https://taskfile.dev/
---
env:
DATABASE_URL: "postgresql://:@/edrn"
EDRN_DATA_DIR: "{{.HOME}}/dockerdata/renaissance"
jpl_ipv4: "172.16.16.10"
LDAP_BIND_PASSWORD: "{{.edrn_service_password}}"
LDAP_URI: "ldaps://localhost:1636"
p5_media_dir: "/Users/kelly/P6/media"
p5_sql: "/Users/kelly/P6/edrn.sql.bz2"
port: 6468
python: "python3.11"
tasks:
clean:
desc: "P5 Python virtual environment destruction"
summary: "Completely removes the Python venv used by P5."
preconditions:
- test -d .venv
cmds:
- rm -rf .venv
venv:
desc: "P5 Python virtual environment"
summary: "Creates the Python venv for P5 by running `pip install` on each src component."
sources:
- Taskfile.yaml
generates:
- .venv/**
cmds:
- "rm -rf .venv"
- "{{.python}} -m venv .venv"
# Curiously, we get different behavior between `python -m pip install` and `pip install`.
# The former doesn't install packages' scripts, but the latter does. We need the scripts.
- ".venv/bin/pip install --quiet --upgrade setuptools pip wheel build"
- ".venv/bin/pip install --editable 'src/eke.geocoding[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.streams[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.controls[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.content[dev]'"
- ".venv/bin/pip install --editable 'src/edrn.collabgroups[dev]'"
- ".venv/bin/pip install --editable 'src/eke.knowledge[dev]'"
- ".venv/bin/pip install --editable 'src/eke.biomarkers[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.search[dev]'"
- ".venv/bin/pip install --editable 'src/edrn.theme[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.ploneimport[dev]'"
- ".venv/bin/pip install --editable 'src/edrn.metrics[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.policy[dev]'"
- ".venv/bin/pip install --editable 'src/edrnsite.test[dev]'"
dev-rebuild:
desc: "Rebuild entire P5 for local development"
summary: >
Erases the local PostgreSQL database and media blobs, imports the latest from the JPL host,
upgrades it to the current development schema, and optionally ingests the latest RDF.
To disable the RDF ingest, use `task dev-rebuild rdf=false`.
⚠️ Warning! This erases any local database or blobs you may have!
deps: [venv]
silent: false
interactive: false
vars:
rdf: "{{.rdf | default \"true\"}}"
cmds:
- echo "⏱️ Starting in 5 seconds; doing RDF ingest is {{.rdf}}"
- sleep 5
- dropdb --force --if-exists "edrn"
- createdb "edrn" "P5 for the Early Detection Research Network"
- rsync --checksum --no-motd --recursive --delete --progress {{.jpl_ipv4}}:{{.p5_media_dir}} .
- touch media/.nobackup
# We could just "ssh cat" this but I like having an extra copy of the .sql.bz2 file locally
# in case of disaster.
- scp {{.jpl_ipv4}}:{{.p5_sql}} .
- bzip2 --decompress --stdout edrn.sql.bz2 | psql --dbname=edrn --echo-errors --quiet
- .venv/bin/django-admin makemigrations --settings local --pythonpath .
- .venv/bin/django-admin migrate --settings local --pythonpath .
- .venv/bin/django-admin copy_daily_hits_from_wagtailsearch --settings local --pythonpath .
- .venv/bin/django-admin collectstatic --settings local --pythonpath . --no-input --clear --link
# Add additional upgrade steps here
- .venv/bin/django-admin edrn_audit_log --settings local --pythonpath .
# End of additional ugprade steps
- .venv/bin/django-admin edrndevreset --settings local --pythonpath .
- "{{.rdf}} -eq true && .venv/bin/django-admin rdfingest --settings local --pythonpath . || true"
- .venv/bin/django-admin clear_cache --settings local --pythonpath . --all
manage:
desc: "Local P5 Django admin"
summary: >
Run Django admin with a command=value command, defaults to shell_plus. For example, to do an RDF
ingest, run `task manage command=rdfingest`. For command-specific arguments, pass them after `--`.
For example: `task manage command=ping_google -- https://my.com/sitemap.xml`.
deps: [venv]
aliases: [shell]
silent: true
interactive: true
vars:
command: "{{.command | default \"shell_plus\"}}"
cmds:
- .venv/bin/django-admin {{.command}} --settings local --pythonpath . {{.CLI_ARGS}}
run:
desc: "Local P5 Django server"
summary: >
Run the Django lightweight web server for development and serving of static files. The
port is {{.port}} and can be overriden: `task run port=1234`.
aliases: [default]
deps: [venv]
# I thought we could use "task:" here to have one task call the "manage" task, but it doesn't
# work at all.
silent: true
interactive: true
cmds:
- .venv/bin/django-admin runserver --settings local --pythonpath . {{.port}}
image:
desc: "P5 Docker image construction"
summary: >
Build the dependent wheels and the P5 Docker image. To skip the wheels, do
`task image wheels=false`
interactive: false
vars:
wheels: "{{.wheels | default \"true\"}}"
cmds:
- "{{.wheels}} -eq true && support/build-wheels.sh || true"
- docker buildx build --build-arg userid=500 --tag edrndocker/edrn-portal:latest --file docker/Dockerfile --load .
comp-portal-exec:
desc: "P5 Docker foreground composition interactive exec in portal"
summary: "For when you need a handy shell inside the portal container in a running Docker composition."
interactive: true
env:
ALLOWED_HOSTS: "*"
CERT_CN: "dev.dev"
EDRN_VERSION: "latest"
LDAP_URI: "ldaps://host.docker.internal:1636"
POSTGRES_PASSWORD: "s3cr3t"
SECURE_COOKIES: "False"
SIGNING_KEY: "s3cret"
cmds:
- docker compose --file docker/docker-compose.yaml exec portal sh
comp-portal-restart:
desc: "P5 Docker foreground composition restart portal"
summary: "In a running Docker composition for P5, this restarts the portal service only."
interactive: false
env:
ALLOWED_HOSTS: "*"
CERT_CN: "dev.dev"
EDRN_VERSION: "latest"
LDAP_URI: "ldaps://host.docker.internal:1636"
POSTGRES_PASSWORD: "s3cr3t"
SECURE_COOKIES: "False"
SIGNING_KEY: "s3cret"
cmds:
- docker compose --file docker/docker-compose.yaml restart portal
comp-up:
desc: "P5 Docker foreground composition running"
summary: "Starts the P5 Docker composition by bringing it `up` in the foreground."
interactive: false
env:
ALLOWED_HOSTS: "*"
CERT_CN: "dev.dev"
EDRN_VERSION: "latest"
LDAP_URI: "ldaps://host.docker.internal:1636"
POSTGRES_PASSWORD: "s3cr3t"
SECURE_COOKIES: "False"
SIGNING_KEY: "s3cret"
cmds:
- docker compose --file docker/docker-compose.yaml up --remove-orphans
dotenv: ['env', '{{.HOME}}/.secrets/passwords.sh']
version: '3'
...
# -*- mode: YAML; tab-width: 4 -*-